Browse Source

Allow timestamping log entries

refactor-mempool
Roman Zeyde 6 years ago
parent
commit
4cc417232d
No known key found for this signature in database GPG Key ID: 87CAE5FA46917CBB
  1. 5
      src/bin/electrs.rs
  2. 7
      src/config.rs

5
src/bin/electrs.rs

@ -52,6 +52,11 @@ fn main() {
stderrlog::new()
.module(module_path!())
.verbosity(config.verbosity)
.timestamp(if config.timestamp {
stderrlog::Timestamp::Microsecond
} else {
stderrlog::Timestamp::Off
})
.init()
.expect("logging initialization failed");
if let Err(e) = run_server(&config) {

7
src/config.rs

@ -5,6 +5,7 @@ use std::net::SocketAddr;
#[derive(Debug)]
pub struct Config {
pub verbosity: usize,
pub timestamp: bool,
pub network_type: Network, // bitcoind JSONRPC endpoint
pub db_path: String, // RocksDB directory path
pub rpc_addr: SocketAddr, // for serving Electrum clients
@ -21,6 +22,11 @@ impl Config {
.multiple(true)
.help("Increase logging verbosity"),
)
.arg(
Arg::with_name("timestamp")
.long("timestamp")
.help("Prepend log lines with a timestamp"),
)
.arg(
Arg::with_name("db_dir")
.short("d")
@ -41,6 +47,7 @@ impl Config {
let db_dir = m.value_of("db_dir").unwrap_or("./db");
Config {
verbosity: m.occurrences_of("verbosity") as usize,
timestamp: m.is_present("timestamp"),
network_type,
db_path: match network_type {
Network::Mainnet => format!("{}/mainnet", db_dir),

Loading…
Cancel
Save