Skip to content

Commit

Permalink
splitting part of util into smaller crates (openethereum#4956)
Browse files Browse the repository at this point in the history
* split path module from util

* moved RotatingLogger from util to logger crate

* fix tests

* fix tests

* use only one version of ansi_term crate
  • Loading branch information
debris authored Mar 22, 2017
1 parent 63f1ca9 commit d530cc8
Show file tree
Hide file tree
Showing 42 changed files with 93 additions and 80 deletions.
40 changes: 26 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ num_cpus = "1.2"
number_prefix = "0.2"
rpassword = "0.2.1"
semver = "0.5"
ansi_term = "0.7"
ansi_term = "0.9"
regex = "0.1"
isatty = "0.1"
toml = "0.2"
Expand Down Expand Up @@ -50,6 +50,7 @@ parity-updater = { path = "updater" }
parity-reactor = { path = "util/reactor" }
parity-local-store = { path = "local-store" }
ethcore-dapps = { path = "dapps", optional = true }
path = { path = "util/path" }
clippy = { version = "0.0.103", optional = true}
ethcore-secretstore = { path = "secret_store", optional = true }

Expand Down
1 change: 1 addition & 0 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ rlp = { path = "../util/rlp" }
ethcore-stratum = { path = "../stratum" }
ethcore-bloom-journal = { path = "../util/bloom" }
hardware-wallet = { path = "../hw" }
ethcore-logger = { path = "../logger" }
stats = { path = "../util/stats" }
num = "0.1"

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use miner::Miner;
use io::IoChannel;

pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
init_log();
::ethcore_logger::init_log();
let tests = ethjson::blockchain::Test::load(json_data).unwrap();
let mut failed = Vec::new();

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use ethereum;
use ethjson;

pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
init_log();
::ethcore_logger::init_log();
let tests = ethjson::state::Test::load(json_data).unwrap();
let mut failed = Vec::new();
let engine = match era {
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extern crate ethcore_stratum;
extern crate ethabi;
extern crate hardware_wallet;
extern crate stats;
extern crate ethcore_logger;
extern crate num;

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/miner/price_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl PriceInfo {
fn should_get_price_info() {
use std::sync::Arc;
use std::time::Duration;
use util::log::init_log;
use ethcore_logger::init_log;
use util::{Condvar, Mutex};

init_log();
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/miner/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,7 @@ pub mod test {

#[test]
fn should_replace_same_transaction_when_has_higher_fee() {
use ethcore_logger::init_log;
init_log();
// given
let mut txq = TransactionQueue::default();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ mod tests {
use env_info::EnvInfo;
use spec::*;
use transaction::*;
use util::log::init_log;
use ethcore_logger::init_log;
use trace::{FlatTrace, TraceError, trace};
use types::executed::CallType;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ mod tests {
use util::{U256, H256, Address, DBTransaction};
use tests::helpers::*;
use state::{Account, Backend};
use util::log::init_log;
use ethcore_logger::init_log;

#[test]
fn state_db_smoke() {
Expand Down
4 changes: 3 additions & 1 deletion logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ authors = ["Parity Technologies <[email protected]>"]
[dependencies]
log = "0.3"
env_logger = "0.3"
ethcore-util = { path = "../util" }
isatty = "0.1"
lazy_static = "0.2"
regex = "0.1"
time = "0.1"
parking_lot = "0.3"
arrayvec = "0.3"
ansi_term = "0.9"

[profile.release]
debug = true
Expand Down
12 changes: 9 additions & 3 deletions logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@

//! Logger for parity executables
extern crate ethcore_util as util;
extern crate arrayvec;
extern crate log as rlog;
extern crate isatty;
extern crate regex;
extern crate env_logger;
extern crate time;
#[macro_use]
extern crate lazy_static;
extern crate parking_lot;
extern crate ansi_term;

mod rotating;

use std::{env, thread, fs};
use std::sync::{Weak, Arc};
use std::io::Write;
use isatty::{stderr_isatty, stdout_isatty};
use env_logger::LogBuilder;
use regex::Regex;
use util::{Mutex, RotatingLogger} ;
use util::log::Colour;
use ansi_term::Colour;
use parking_lot::Mutex;

pub use rotating::{RotatingLogger, init_log};

#[derive(Debug, PartialEq, Clone)]
pub struct Config {
Expand Down
1 change: 0 additions & 1 deletion util/src/log.rs → logger/src/rotating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::env;
use rlog::LogLevelFilter;
use env_logger::LogBuilder;
use arrayvec::ArrayVec;
pub use ansi_term::{Colour, Style};

use parking_lot::{RwLock, RwLockReadGuard};

Expand Down
4 changes: 2 additions & 2 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::cmp::max;
use cli::{Args, ArgsError};
use util::{Hashable, H256, U256, Uint, Bytes, version_data, Address};
use util::journaldb::Algorithm;
use util::log::Colour;
use util::Colour;
use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP};
use ethcore::ethstore::ethkey::Secret;
use ethcore::client::{VMType};
Expand Down Expand Up @@ -824,7 +824,7 @@ impl Configuration {
}

fn directories(&self) -> Directories {
use util::path;
use path;

let local_path = default_local_path();
let base_path = self.args.flag_base_path.as_ref().map_or_else(|| default_data_path(), |s| s.clone());
Expand Down
5 changes: 3 additions & 2 deletions parity/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{io, env};
use std::io::{Write, BufReader, BufRead};
use std::time::Duration;
use std::fs::File;
use util::{clean_0x, U256, Uint, Address, path, CompactionProfile};
use util::{clean_0x, U256, Uint, Address, CompactionProfile};
use util::journaldb::Algorithm;
use ethcore::client::{Mode, BlockId, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::miner::{PendingSet, GasLimit, PrioritizationStrategy};
Expand All @@ -27,6 +27,7 @@ use dir::DatabaseDirectories;
use upgrade::{upgrade, upgrade_data_paths};
use migration::migrate;
use ethsync::is_valid_node_url;
use path;

pub fn to_duration(s: &str) -> Result<Duration, String> {
to_seconds(s).map(Duration::from_secs)
Expand Down Expand Up @@ -465,7 +466,7 @@ but the first password is trimmed
#[test]
#[cfg(not(windows))]
fn test_geth_ipc_path() {
use util::path;
use path;
assert_eq!(geth_ipc_path(true), path::ethereum::with_testnet("geth.ipc").to_str().unwrap().to_owned());
assert_eq!(geth_ipc_path(false), path::ethereum::with_default("geth.ipc").to_str().unwrap().to_owned());
}
Expand Down
1 change: 1 addition & 0 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extern crate parity_reactor;
extern crate parity_updater as updater;
extern crate parity_local_store as local_store;
extern crate rpc_cli;
extern crate path;

#[macro_use]
extern crate log as rlog;
Expand Down
2 changes: 1 addition & 1 deletion parity/rpc_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ethsync::{ManageNetwork, SyncProvider};
use hash_fetch::fetch::Client as FetchClient;
use jsonrpc_core::{MetaIoHandler};
use updater::Updater;
use util::RotatingLogger;
use ethcore_logger::RotatingLogger;

#[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum Api {
Expand Down
4 changes: 2 additions & 2 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use ctrlc::CtrlC;
use fdlimit::raise_fd_limit;
use ethcore_rpc::{NetworkSettings, informant, is_major_importing};
use ethsync::NetworkConfiguration;
use util::{Colour, version, RotatingLogger, Mutex, Condvar};
use util::{Colour, version, Mutex, Condvar};
use io::{MayPanic, ForwardPanic, PanicHandler};
use ethcore_logger::{Config as LogConfig};
use ethcore_logger::{Config as LogConfig, RotatingLogger};
use ethcore::miner::{StratumOptions, Stratum};
use ethcore::client::{Client, Mode, DatabaseCompactionProfile, VMType, BlockChainClient};
use ethcore::service::ClientService;
Expand Down
Loading

0 comments on commit d530cc8

Please sign in to comment.