pub static LOGGER: LazyLock<RwLock<Logger>>Expand description
Global Logger struct that can be used with the debug!, info!, warn!,
err!, and fatal! macros.
Note Do not use any log macros when you are writing to the global logger, it will cause your thread to lock.
This will block the thread:
// Get write access to the logger
let mut logger = LOGGER.write().unwrap();
// Trying to use logging macro blocks the thread
info!("This will never be shown!");ยงExamples
Using global logging:
debug!("This is a debug message!");
info!("This is an info message!");
warn!("This is a warning!");
err!("This is an error!");
fatal!("This is a fatal error!");Configuring the global logger:
// Configure logger
let mut logger = LOGGER.write().unwrap();
logger.set_verbosity(Verbosity::All);
// Drop the logger so a read lock can be acquired
drop(logger);
// Then print a message
debug!("This should be shown!");