Merge branch 'master' into noui
Conflicts: Cargo.toml
This commit is contained in:
commit
e0f6709f05
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -22,9 +22,11 @@ dependencies = [
|
|||||||
"fdlimit 0.1.0",
|
"fdlimit 0.1.0",
|
||||||
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)",
|
"json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)",
|
||||||
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rpassword 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rpassword 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -862,7 +864,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps"
|
name = "parity-dapps"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/ethcore/parity-ui.git#4c5a972e81379cbf96fe6119a127d3540de14b1b"
|
source = "git+https://github.com/ethcore/parity-ui.git#f16a7e8b7f1ea4fe4da12af22f36a745a07513d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -876,7 +878,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-home"
|
name = "parity-dapps-home"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
source = "git+https://github.com/ethcore/parity-ui.git#4c5a972e81379cbf96fe6119a127d3540de14b1b"
|
source = "git+https://github.com/ethcore/parity-ui.git#f16a7e8b7f1ea4fe4da12af22f36a745a07513d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
||||||
]
|
]
|
||||||
@ -884,7 +886,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-signer"
|
name = "parity-dapps-signer"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/ethcore/parity-ui.git#4c5a972e81379cbf96fe6119a127d3540de14b1b"
|
source = "git+https://github.com/ethcore/parity-ui.git#f16a7e8b7f1ea4fe4da12af22f36a745a07513d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
||||||
]
|
]
|
||||||
@ -892,7 +894,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-status"
|
name = "parity-dapps-status"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/ethcore/parity-ui.git#4c5a972e81379cbf96fe6119a127d3540de14b1b"
|
source = "git+https://github.com/ethcore/parity-ui.git#f16a7e8b7f1ea4fe4da12af22f36a745a07513d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
||||||
]
|
]
|
||||||
@ -900,7 +902,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-wallet"
|
name = "parity-dapps-wallet"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/ethcore/parity-ui.git#4c5a972e81379cbf96fe6119a127d3540de14b1b"
|
source = "git+https://github.com/ethcore/parity-ui.git#f16a7e8b7f1ea4fe4da12af22f36a745a07513d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-ui.git)",
|
||||||
]
|
]
|
||||||
|
12
Cargo.toml
12
Cargo.toml
@ -17,25 +17,27 @@ env_logger = "0.3"
|
|||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
docopt = "0.6"
|
docopt = "0.6"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
ctrlc = { git = "https://github.com/ethcore/rust-ctrlc.git" }
|
|
||||||
fdlimit = { path = "util/fdlimit" }
|
|
||||||
num_cpus = "0.2"
|
num_cpus = "0.2"
|
||||||
number_prefix = "0.2"
|
number_prefix = "0.2"
|
||||||
rpassword = "0.2.1"
|
rpassword = "0.2.1"
|
||||||
clippy = { version = "0.0.79", optional = true}
|
semver = "0.2"
|
||||||
|
ansi_term = "0.7"
|
||||||
|
lazy_static = "0.2"
|
||||||
|
regex = "0.1"
|
||||||
|
ctrlc = { git = "https://github.com/ethcore/rust-ctrlc.git" }
|
||||||
|
fdlimit = { path = "util/fdlimit" }
|
||||||
ethcore = { path = "ethcore" }
|
ethcore = { path = "ethcore" }
|
||||||
ethcore-util = { path = "util" }
|
ethcore-util = { path = "util" }
|
||||||
ethsync = { path = "sync" }
|
ethsync = { path = "sync" }
|
||||||
ethcore-devtools = { path = "devtools" }
|
ethcore-devtools = { path = "devtools" }
|
||||||
ethcore-rpc = { path = "rpc" }
|
ethcore-rpc = { path = "rpc" }
|
||||||
ethcore-signer = { path = "signer" }
|
ethcore-signer = { path = "signer" }
|
||||||
semver = "0.2"
|
|
||||||
ethcore-ipc-nano = { path = "ipc/nano" }
|
ethcore-ipc-nano = { path = "ipc/nano" }
|
||||||
ethcore-ipc = { path = "ipc/rpc" }
|
ethcore-ipc = { path = "ipc/rpc" }
|
||||||
ethcore-ipc-hypervisor = { path = "ipc/hypervisor" }
|
ethcore-ipc-hypervisor = { path = "ipc/hypervisor" }
|
||||||
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
|
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
|
||||||
ansi_term = "0.7"
|
|
||||||
ethcore-dapps = { path = "dapps", optional = true }
|
ethcore-dapps = { path = "dapps", optional = true }
|
||||||
|
clippy = { version = "0.0.79", optional = true}
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = "0.2"
|
winapi = "0.2"
|
||||||
|
@ -264,6 +264,8 @@ Legacy Options:
|
|||||||
Miscellaneous Options:
|
Miscellaneous Options:
|
||||||
-l --logging LOGGING Specify the logging level. Must conform to the same
|
-l --logging LOGGING Specify the logging level. Must conform to the same
|
||||||
format as RUST_LOG.
|
format as RUST_LOG.
|
||||||
|
--log-file FILENAME Specify a filename into which logging should be
|
||||||
|
directed.
|
||||||
--no-color Don't use terminal color codes in output.
|
--no-color Don't use terminal color codes in output.
|
||||||
-v --version Show information about version.
|
-v --version Show information about version.
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
@ -339,7 +341,7 @@ pub struct Args {
|
|||||||
pub flag_author: Option<String>,
|
pub flag_author: Option<String>,
|
||||||
pub flag_usd_per_tx: String,
|
pub flag_usd_per_tx: String,
|
||||||
pub flag_usd_per_eth: String,
|
pub flag_usd_per_eth: String,
|
||||||
pub flag_price_update_period: String,
|
pub flag_price_update_period: String,
|
||||||
pub flag_gas_floor_target: String,
|
pub flag_gas_floor_target: String,
|
||||||
pub flag_gas_cap: String,
|
pub flag_gas_cap: String,
|
||||||
pub flag_extra_data: Option<String>,
|
pub flag_extra_data: Option<String>,
|
||||||
@ -351,6 +353,7 @@ pub struct Args {
|
|||||||
pub flag_to: String,
|
pub flag_to: String,
|
||||||
pub flag_format: Option<String>,
|
pub flag_format: Option<String>,
|
||||||
pub flag_jitvm: bool,
|
pub flag_jitvm: bool,
|
||||||
|
pub flag_log_file: Option<String>,
|
||||||
pub flag_no_color: bool,
|
pub flag_no_color: bool,
|
||||||
pub flag_no_network: bool,
|
pub flag_no_network: bool,
|
||||||
// legacy...
|
// legacy...
|
||||||
|
@ -50,6 +50,9 @@ extern crate ethcore_rpc;
|
|||||||
|
|
||||||
extern crate ethcore_signer;
|
extern crate ethcore_signer;
|
||||||
extern crate ansi_term;
|
extern crate ansi_term;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
extern crate regex;
|
||||||
|
|
||||||
#[cfg(feature = "dapps")]
|
#[cfg(feature = "dapps")]
|
||||||
extern crate ethcore_dapps;
|
extern crate ethcore_dapps;
|
||||||
@ -184,7 +187,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
|||||||
let panic_handler = PanicHandler::new_in_arc();
|
let panic_handler = PanicHandler::new_in_arc();
|
||||||
|
|
||||||
// Setup logging
|
// Setup logging
|
||||||
let logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color());
|
let logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color(), &conf.args.flag_log_file);
|
||||||
// Raise fdlimit
|
// Raise fdlimit
|
||||||
unsafe { ::fdlimit::raise_fd_limit(); }
|
unsafe { ::fdlimit::raise_fd_limit(); }
|
||||||
|
|
||||||
@ -342,7 +345,7 @@ fn execute_export(conf: Configuration) {
|
|||||||
let panic_handler = PanicHandler::new_in_arc();
|
let panic_handler = PanicHandler::new_in_arc();
|
||||||
|
|
||||||
// Setup logging
|
// Setup logging
|
||||||
let _logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color());
|
let _logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color(), &conf.args.flag_log_file);
|
||||||
// Raise fdlimit
|
// Raise fdlimit
|
||||||
unsafe { ::fdlimit::raise_fd_limit(); }
|
unsafe { ::fdlimit::raise_fd_limit(); }
|
||||||
|
|
||||||
@ -403,7 +406,7 @@ fn execute_import(conf: Configuration) {
|
|||||||
let panic_handler = PanicHandler::new_in_arc();
|
let panic_handler = PanicHandler::new_in_arc();
|
||||||
|
|
||||||
// Setup logging
|
// Setup logging
|
||||||
let _logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color());
|
let _logger = setup_log::setup_log(&conf.args.flag_logging, conf.have_color(), &conf.args.flag_log_file);
|
||||||
// Raise fdlimit
|
// Raise fdlimit
|
||||||
unsafe { ::fdlimit::raise_fd_limit(); }
|
unsafe { ::fdlimit::raise_fd_limit(); }
|
||||||
|
|
||||||
|
@ -17,12 +17,16 @@
|
|||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
use time;
|
use time;
|
||||||
use env_logger::LogBuilder;
|
use env_logger::LogBuilder;
|
||||||
|
use regex::Regex;
|
||||||
use util::RotatingLogger;
|
use util::RotatingLogger;
|
||||||
|
use util::log::{Applyable, Colour};
|
||||||
|
|
||||||
/// Sets up the logger
|
/// Sets up the logger
|
||||||
pub fn setup_log(init: &Option<String>, enable_color: bool) -> Arc<RotatingLogger> {
|
pub fn setup_log(init: &Option<String>, enable_color: bool, log_to_file: &Option<String>) -> Arc<RotatingLogger> {
|
||||||
use rlog::*;
|
use rlog::*;
|
||||||
|
|
||||||
let mut levels = String::new();
|
let mut levels = String::new();
|
||||||
@ -45,14 +49,24 @@ pub fn setup_log(init: &Option<String>, enable_color: bool) -> Arc<RotatingLogge
|
|||||||
|
|
||||||
let logs = Arc::new(RotatingLogger::new(levels, enable_color));
|
let logs = Arc::new(RotatingLogger::new(levels, enable_color));
|
||||||
let logger = logs.clone();
|
let logger = logs.clone();
|
||||||
|
let maybe_file = log_to_file.as_ref().map(|f| File::create(f).unwrap_or_else(|_| die!("Cannot write to log file given: {}", f)));
|
||||||
let format = move |record: &LogRecord| {
|
let format = move |record: &LogRecord| {
|
||||||
let timestamp = time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap();
|
let timestamp = time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap();
|
||||||
|
|
||||||
let format = if max_log_level() <= LogLevelFilter::Info {
|
let format = if max_log_level() <= LogLevelFilter::Info {
|
||||||
format!("{}{}", timestamp, record.args())
|
format!("{}{}", timestamp.apply(Colour::Black.bold()), record.args())
|
||||||
} else {
|
} else {
|
||||||
format!("{}{}:{}: {}", timestamp, record.level(), record.target(), record.args())
|
format!("{}{}:{}: {}", timestamp.apply(Colour::Black.bold()), record.level(), record.target(), record.args())
|
||||||
};
|
};
|
||||||
logger.append(format.clone());
|
|
||||||
|
let removed_color = kill_color(format.as_ref());
|
||||||
|
if let Some(mut file) = maybe_file.as_ref() {
|
||||||
|
// ignore errors - there's nothing we can do
|
||||||
|
let _ = file.write_all(removed_color.as_bytes());
|
||||||
|
let _ = file.write_all(b"\n");
|
||||||
|
}
|
||||||
|
logger.append(removed_color);
|
||||||
|
|
||||||
format
|
format
|
||||||
};
|
};
|
||||||
builder.format(format);
|
builder.format(format);
|
||||||
@ -60,3 +74,23 @@ pub fn setup_log(init: &Option<String>, enable_color: bool) -> Arc<RotatingLogge
|
|||||||
logs
|
logs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn kill_color(s: &str) -> String {
|
||||||
|
lazy_static! {
|
||||||
|
static ref RE: Regex = Regex::new("\x1b\\[[^m]+m").unwrap();
|
||||||
|
}
|
||||||
|
RE.replace_all(s, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_remove_colour() {
|
||||||
|
let before = "test";
|
||||||
|
let after = kill_color(&before.apply(Colour::Red.bold()));
|
||||||
|
assert_eq!(after, "test");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_remove_multiple_colour() {
|
||||||
|
let t = format!("{} {}", Colour::Red.bold().paint("test"), Colour::White.normal().paint("again"));
|
||||||
|
let after = kill_color(&t);
|
||||||
|
assert_eq!(after, "test again");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user