diff --git a/Cargo.toml b/Cargo.toml index 586605849..ebfc2f1a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ daemonize = "^0.2.3" serde = "~1.0.8" serde_derive = "~1.0.8" serde_json = "~1.0.2" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } # TODO - once "patch" is available we should be able to clean up the workspace dependencies # [patch.crate-io] diff --git a/api/Cargo.toml b/api/Cargo.toml index d8c2f401e..cd63533cd 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -12,7 +12,7 @@ grin_store = { path = "../store" } grin_util = { path = "../util" } secp256k1zkp = { git = "https://github.com/mimblewimble/rust-secp256k1-zkp" } hyper = "~0.10.6" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } iron = "~0.5.1" router = "~0.5.1" serde = "~1.0.8" diff --git a/chain/Cargo.toml b/chain/Cargo.toml index 59d1ace21..03849f119 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -7,7 +7,7 @@ workspace = ".." [dependencies] bitflags = "^0.7.0" byteorder = "^0.5" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } serde = "~1.0.8" serde_derive = "~1.0.8" time = "^0.1" diff --git a/doc/build.md b/doc/build.md index 63b3f9cd9..483616ba9 100644 --- a/doc/build.md +++ b/doc/build.md @@ -102,12 +102,12 @@ Before running your mining server, a wallet server needs to be set up and listen node1$ grin wallet -p "password" receive -This will create a wallet server listening on the default port 13415 with the password "password". Next, in another terminal window in the 'node1' directory, run a full mining node with the following command: +This will create a wallet server listening on the default port 13416 with the password "password". Next, in another terminal window in the 'node1' directory, run a full mining node with the following command: node1$ grin server -m run This creates a new .grin database directory in the current directory, and begins mining new blocks (with no transactions, for now). Note this starts two services listening on two default ports, -port 13414 for the peer-to-peer (P2P) service which keeps all nodes synchronised, and 13415 for the Rest API service used to verify transactions and post new transactions to the pool (for example). These ports can be configured via command line switches, or via a grin.toml file in the working directory. +port 13414 for the peer-to-peer (P2P) service which keeps all nodes synchronised, and 13413 for the Rest API service used to verify transactions and post new transactions to the pool (for example). These ports can be configured via command line switches, or via a grin.toml file in the working directory. Let the mining server find a few blocks, then stop (just ctrl-c) the mining server and the wallet server. You'll notice grin has created a database directory (.grin) in which the blockchain and peer data is stored. There should also be a wallet.dat file in the current directory, which contains a few coinbase mining rewards created each time the server mines a new block. diff --git a/grin/Cargo.toml b/grin/Cargo.toml index ad8c52a0f..1a2eb6fad 100644 --- a/grin/Cargo.toml +++ b/grin/Cargo.toml @@ -20,7 +20,7 @@ secp256k1zkp = { git = "https://github.com/mimblewimble/rust-secp256k1-zkp" } futures = "^0.1.15" futures-cpupool = "^0.1.3" hyper = { git = "https://github.com/hyperium/hyper" } -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } time = "^0.1" serde = "~1.0.8" serde_derive = "~1.0.8" diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 0a95a8ea5..eca81a2ae 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -8,7 +8,7 @@ workspace = ".." bitflags = "^0.7.0" byteorder = "^0.5" futures = "^0.1.15" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } net2 = "0.2.0" rand = "^0.3" serde = "~1.0.8" diff --git a/pow/Cargo.toml b/pow/Cargo.toml index 20f8f165d..e07d6982b 100644 --- a/pow/Cargo.toml +++ b/pow/Cargo.toml @@ -8,7 +8,7 @@ workspace = ".." blake2-rfc = "~0.2.17" rand = "^0.3" time = "^0.1" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } lazy_static = "~0.2.8" serde = "~1.0.8" serde_derive = "~1.0.8" diff --git a/store/Cargo.toml b/store/Cargo.toml index 30b8e7178..a71f2b778 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -7,7 +7,7 @@ workspace = ".." [dependencies] byteorder = "^0.5" env_logger="^0.3.5" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } libc = "^0.2" memmap = { git = "https://github.com/danburkert/memmap-rs" } rocksdb = "^0.7.0" diff --git a/util/Cargo.toml b/util/Cargo.toml index c863ffeee..25d7f3ad6 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Ignotus Peverell ", workspace = ".." [dependencies] -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } slog-term = "^2.2.0" slog-async = "^2.1.0" lazy_static = "~0.2.8" diff --git a/util/src/logger.rs b/util/src/logger.rs index f1b5da13a..1a38d1739 100644 --- a/util/src/logger.rs +++ b/util/src/logger.rs @@ -20,7 +20,7 @@ use slog_async; use types::{LogLevel, LoggingConfig}; -fn convert_log_level(in_level:&LogLevel)->Level{ +fn convert_log_level(in_level: &LogLevel) -> Level { match *in_level { LogLevel::Info => Level::Info, LogLevel::Critical => Level::Critical, @@ -32,10 +32,13 @@ fn convert_log_level(in_level:&LogLevel)->Level{ } lazy_static! { + /// Flag to observe whether logging was explcitly initialised (don't output otherwise) + static ref WAS_INIT: Mutex = Mutex::new(false); /// Static Logging configuration, should only be set once, before first logging call static ref LOGGING_CONFIG: Mutex = Mutex::new(LoggingConfig::default()); /// And a static reference to the logger itself, accessible from all crates pub static ref LOGGER: Logger = { + let was_init = WAS_INIT.lock().unwrap().clone(); let config = LOGGING_CONFIG.lock().unwrap(); let slog_level_stdout = convert_log_level(&config.stdout_log_level); let slog_level_file = convert_log_level(&config.file_log_level); @@ -46,13 +49,13 @@ lazy_static! { let terminal_drain = LevelFilter::new(terminal_drain, slog_level_stdout).fuse(); let mut terminal_drain = slog_async::Async::new(terminal_drain).build().fuse(); - if !config.log_to_stdout { + if !config.log_to_stdout || !was_init { terminal_drain = slog_async::Async::new(Discard{}).build().fuse(); } let mut file_drain_final = slog_async::Async::new(Discard{}).build().fuse(); - if config.log_to_file { + if config.log_to_file && was_init { //File drain let file = OpenOptions::new() .create(true) @@ -73,15 +76,16 @@ lazy_static! { let log = Logger::root(composite_drain, o!()); log - }; + }; } /// Initialises the logger with the given configuration -pub fn init_logger(config:Option){ +pub fn init_logger(config: Option) { if let Some(c) = config { - let mut config_ref=LOGGING_CONFIG.lock().unwrap(); - *config_ref=c.clone(); + let mut config_ref = LOGGING_CONFIG.lock().unwrap(); + *config_ref = c.clone(); + let mut was_init_ref = WAS_INIT.lock().unwrap(); + *was_init_ref = true; } - } diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index 04c84d3bc..ec7e289e0 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -10,7 +10,7 @@ authors = [ [dependencies] byteorder = "1" -slog = "^2.0.12" +slog = { version = "^2.0.12", features = ["max_level_trace", "release_max_level_trace"] } rand = "^0.3" blake2-rfc = "~0.2.17" serde = "~1.0.8"