tweaks to logging configuration (#176)

* tweaks to logging configuration
* doc port update
This commit is contained in:
Yeastplume 2017-10-13 17:42:04 +01:00 committed by Ignotus Peverell
parent dda10a6dee
commit 49797853d9
11 changed files with 23 additions and 19 deletions

View file

@ -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]

View file

@ -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"

View file

@ -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"

View file

@ -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.

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -6,7 +6,7 @@ authors = ["Ignotus Peverell <igno.peverell@protonmail.com>",
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"

View file

@ -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<bool> = Mutex::new(false);
/// Static Logging configuration, should only be set once, before first logging call
static ref LOGGING_CONFIG: Mutex<LoggingConfig> = 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<LoggingConfig>){
pub fn init_logger(config: Option<LoggingConfig>) {
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;
}
}

View file

@ -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"