Adds verbosity cli flag
This commit is contained in:
parent
8d5d228270
commit
ad1438db53
@ -22,3 +22,4 @@ tokio-timer = "0.2.10"
|
|||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
exit-future = "0.1.3"
|
exit-future = "0.1.3"
|
||||||
state_processing = { path = "../eth2/state_processing" }
|
state_processing = { path = "../eth2/state_processing" }
|
||||||
|
slog = { version = "^2.2.3" , features = ["max_level_trace", "release_max_level_debug"] }
|
||||||
|
@ -19,7 +19,9 @@ slot_clock = { path = "../../eth2/utils/slot_clock" }
|
|||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
error-chain = "0.12.0"
|
error-chain = "0.12.0"
|
||||||
slog = "^2.2.3"
|
slog = { version = "^2.2.3" , features = ["max_level_trace", "release_max_level_debug"] }
|
||||||
|
slog-term = "^2.4.0"
|
||||||
|
slog-async = "^2.3.0"
|
||||||
ssz = { path = "../../eth2/utils/ssz" }
|
ssz = { path = "../../eth2/utils/ssz" }
|
||||||
tokio = "0.1.15"
|
tokio = "0.1.15"
|
||||||
clap = "2.32.0"
|
clap = "2.32.0"
|
||||||
|
@ -7,7 +7,7 @@ use http_server::HttpServerConfig;
|
|||||||
use network::NetworkConfig;
|
use network::NetworkConfig;
|
||||||
use network::{ChainType, NetworkConfig};
|
use network::{ChainType, NetworkConfig};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use slog::error;
|
use slog::{error, o, Drain, Level};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@ -57,13 +57,6 @@ impl ClientConfig {
|
|||||||
.and_then(|path| Some(path.join(&self.db_name)))
|
.and_then(|path| Some(path.join(&self.db_name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the core path for the client.
|
|
||||||
pub fn data_dir(&self) -> Option<PathBuf> {
|
|
||||||
let path = dirs::home_dir()?.join(&self.data_dir);
|
|
||||||
fs::create_dir_all(&path).ok()?;
|
|
||||||
Some(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply the following arguments to `self`, replacing values if they are specified in `args`.
|
/// Apply the following arguments to `self`, replacing values if they are specified in `args`.
|
||||||
///
|
///
|
||||||
/// Returns an error if arguments are obviously invalid. May succeed even if some values are
|
/// Returns an error if arguments are obviously invalid. May succeed even if some values are
|
||||||
@ -81,6 +74,6 @@ impl ClientConfig {
|
|||||||
self.rpc.apply_cli_args(args)?;
|
self.rpc.apply_cli_args(args)?;
|
||||||
self.http.apply_cli_args(args)?;
|
self.http.apply_cli_args(args)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,8 @@ impl<TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess<KademliaOu
|
|||||||
{
|
{
|
||||||
fn inject_event(&mut self, out: KademliaOut) {
|
fn inject_event(&mut self, out: KademliaOut) {
|
||||||
match out {
|
match out {
|
||||||
KademliaOut::Discovered { .. } => {
|
KademliaOut::Discovered { peer_id, .. } => {
|
||||||
|
debug!(self.log, "Kademlia peer discovered: {:?}", peer_id);
|
||||||
// send this to our topology behaviour
|
// send this to our topology behaviour
|
||||||
}
|
}
|
||||||
KademliaOut::KBucketAdded { .. } => {
|
KademliaOut::KBucketAdded { .. } => {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
extern crate slog;
|
|
||||||
|
|
||||||
mod run;
|
mod run;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
@ -14,11 +12,6 @@ pub const CLIENT_CONFIG_FILENAME: &str = "beacon-node.toml";
|
|||||||
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
|
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let decorator = slog_term::TermDecorator::new().build();
|
|
||||||
let drain = slog_term::CompactFormat::new(decorator).build().fuse();
|
|
||||||
let drain = slog_async::Async::new(drain).build().fuse();
|
|
||||||
let logger = slog::Logger::root(drain, o!());
|
|
||||||
|
|
||||||
let matches = App::new("Lighthouse")
|
let matches = App::new("Lighthouse")
|
||||||
.version(version::version().as_str())
|
.version(version::version().as_str())
|
||||||
.author("Sigma Prime <contact@sigmaprime.io>")
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
||||||
@ -116,8 +109,29 @@ fn main() {
|
|||||||
.short("r")
|
.short("r")
|
||||||
.help("When present, genesis will be within 30 minutes prior. Only for testing"),
|
.help("When present, genesis will be within 30 minutes prior. Only for testing"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("verbosity")
|
||||||
|
.short("v")
|
||||||
|
.multiple(true)
|
||||||
|
.help("Sets the verbosity level")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
|
// build the initial logger
|
||||||
|
let decorator = slog_term::TermDecorator::new().build();
|
||||||
|
let drain = slog_term::CompactFormat::new(decorator).build().fuse();
|
||||||
|
let drain = slog_async::Async::new(drain).build();
|
||||||
|
|
||||||
|
let drain = match matches.occurrences_of("verbosity") {
|
||||||
|
0 => drain.filter_level(Level::Info),
|
||||||
|
1 => drain.filter_level(Level::Debug),
|
||||||
|
2 => drain.filter_level(Level::Trace),
|
||||||
|
_ => drain.filter_level(Level::Info),
|
||||||
|
};
|
||||||
|
|
||||||
|
let logger = slog::Logger::root(drain.fuse(), o!());
|
||||||
|
|
||||||
let data_dir = match get_data_dir(&matches, PathBuf::from(DEFAULT_DATA_DIR)) {
|
let data_dir = match get_data_dir(&matches, PathBuf::from(DEFAULT_DATA_DIR)) {
|
||||||
Ok(dir) => dir,
|
Ok(dir) => dir,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -128,7 +142,7 @@ fn main() {
|
|||||||
|
|
||||||
let client_config_path = data_dir.join(CLIENT_CONFIG_FILENAME);
|
let client_config_path = data_dir.join(CLIENT_CONFIG_FILENAME);
|
||||||
|
|
||||||
// Attempt to lead the `ClientConfig` from disk.
|
// Attempt to load the `ClientConfig` from disk.
|
||||||
//
|
//
|
||||||
// If file doesn't exist, create a new, default one.
|
// If file doesn't exist, create a new, default one.
|
||||||
let mut client_config = match read_from_file::<ClientConfig>(client_config_path.clone()) {
|
let mut client_config = match read_from_file::<ClientConfig>(client_config_path.clone()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user