mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: verbose flag (#541)
This commit is contained in:
@ -11,7 +11,11 @@ use crate::{
|
||||
/// main function that parses cli and runs command
|
||||
pub async fn run() -> eyre::Result<()> {
|
||||
let opt = Cli::parse();
|
||||
reth_tracing::build_subscriber(if opt.silent { TracingMode::Silent } else { TracingMode::All })
|
||||
reth_tracing::build_subscriber(if opt.silent {
|
||||
TracingMode::Silent
|
||||
} else {
|
||||
TracingMode::from(opt.verbose)
|
||||
})
|
||||
.init();
|
||||
|
||||
match opt.command {
|
||||
|
||||
@ -31,21 +31,45 @@ pub mod reth_tracing {
|
||||
|
||||
/// Tracing modes
|
||||
pub enum TracingMode {
|
||||
/// Enable all info traces.
|
||||
/// Enable all traces.
|
||||
All,
|
||||
/// Disable tracing
|
||||
/// Enable debug traces.
|
||||
Debug,
|
||||
/// Enable info traces.
|
||||
Info,
|
||||
/// Enable warn traces.
|
||||
Warn,
|
||||
/// Enable error traces.
|
||||
Error,
|
||||
/// Disable tracing.
|
||||
Silent,
|
||||
}
|
||||
|
||||
impl TracingMode {
|
||||
fn into_env_filter(self) -> EnvFilter {
|
||||
match self {
|
||||
Self::All => EnvFilter::new("reth=info"),
|
||||
Self::All => EnvFilter::new("reth=trace"),
|
||||
Self::Debug => EnvFilter::new("reth=debug"),
|
||||
Self::Info => EnvFilter::new("reth=info"),
|
||||
Self::Warn => EnvFilter::new("reth=warn"),
|
||||
Self::Error => EnvFilter::new("reth=error"),
|
||||
Self::Silent => EnvFilter::new(""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u8> for TracingMode {
|
||||
fn from(value: u8) -> Self {
|
||||
match value {
|
||||
0 => Self::Error,
|
||||
1 => Self::Warn,
|
||||
2 => Self::Info,
|
||||
3 => Self::Debug,
|
||||
_ => Self::All,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Build subscriber
|
||||
// TODO: JSON/systemd support
|
||||
pub fn build_subscriber(mods: TracingMode) -> impl Subscriber {
|
||||
|
||||
Reference in New Issue
Block a user