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
|
/// main function that parses cli and runs command
|
||||||
pub async fn run() -> eyre::Result<()> {
|
pub async fn run() -> eyre::Result<()> {
|
||||||
let opt = Cli::parse();
|
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();
|
.init();
|
||||||
|
|
||||||
match opt.command {
|
match opt.command {
|
||||||
|
|||||||
@ -31,21 +31,45 @@ pub mod reth_tracing {
|
|||||||
|
|
||||||
/// Tracing modes
|
/// Tracing modes
|
||||||
pub enum TracingMode {
|
pub enum TracingMode {
|
||||||
/// Enable all info traces.
|
/// Enable all traces.
|
||||||
All,
|
All,
|
||||||
/// Disable tracing
|
/// Enable debug traces.
|
||||||
|
Debug,
|
||||||
|
/// Enable info traces.
|
||||||
|
Info,
|
||||||
|
/// Enable warn traces.
|
||||||
|
Warn,
|
||||||
|
/// Enable error traces.
|
||||||
|
Error,
|
||||||
|
/// Disable tracing.
|
||||||
Silent,
|
Silent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TracingMode {
|
impl TracingMode {
|
||||||
fn into_env_filter(self) -> EnvFilter {
|
fn into_env_filter(self) -> EnvFilter {
|
||||||
match self {
|
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(""),
|
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
|
/// Build subscriber
|
||||||
// TODO: JSON/systemd support
|
// TODO: JSON/systemd support
|
||||||
pub fn build_subscriber(mods: TracingMode) -> impl Subscriber {
|
pub fn build_subscriber(mods: TracingMode) -> impl Subscriber {
|
||||||
|
|||||||
Reference in New Issue
Block a user