You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The signal.rs example is difficult to understand as it contains lots of code not related to slog_atomic.
I would propose to add a simpler example that focuses only on the ability of slog_atomic to alter the logger configuration at runtime.
For example, I used this piece of code to show it to my collegues:
use slog::*;use slog_async::Async;fnmain(){let debug_drain = new_drain(Level::Debug);let info_drain = new_drain(Level::Info);let warn_drain = new_drain(Level::Warning);// init AtomicSwitchlet drain = slog_atomic::AtomicSwitch::new(debug_drain);let log_ctrl = drain.ctrl();// Init root logger// Here the global log level is set to DEBUGlet log = slog::Logger::root(drain,o!());println!("------------------");debug!(log,"debug log 1");// this is loggedinfo!(log,"info log 1");// this is loggedwarn!(log,"warn log 1");// this is logged// Change the log level at runtime.// Now the global log level is set to INFO
log_ctrl.set(info_drain);println!("------------------");debug!(log,"debug log 2");// this is NOT logged anymoreinfo!(log,"info log 2");// this is loggedwarn!(log,"warn log 2");// this is logged// Change the log level at runtime.// Now the global log level is set to WARN
log_ctrl.set(warn_drain);println!("------------------");debug!(log,"debug log 3");// this is NOT logged anymoreinfo!(log,"info log 3");// this is NOT logged anymorewarn!(log,"warn log 3");// this is logged}fnnew_drain(level:Level) -> Fuse<LevelFilter<Fuse<Async>>>{let decorator = slog_term::TermDecorator::new().build();let drain = slog_term::FullFormat::new(decorator).build().fuse();let drain = slog_async::Async::new(drain).build().fuse();
drain.filter_level(level).fuse()}
The text was updated successfully, but these errors were encountered:
The
signal.rs
example is difficult to understand as it contains lots of code not related to slog_atomic.I would propose to add a simpler example that focuses only on the ability of slog_atomic to alter the logger configuration at runtime.
For example, I used this piece of code to show it to my collegues:
The text was updated successfully, but these errors were encountered: