Struct simple_logger::SimpleLogger [−][src]
Implementations
impl SimpleLogger
[src]
#[must_use = "You must call init() to begin logging"]pub fn new() -> SimpleLogger
[src]
Initializes the global logger with a SimpleLogger instance with
default log level set to Level::Trace
.
You may use the various builder-style methods on this type to configure
the logger, and you must call init
in order to start logging messages.
use simple_logger::SimpleLogger; SimpleLogger::new().init().unwrap(); log::warn!("This is an example message.");
#[must_use = "You must call init() to begin logging"]pub fn from_env() -> SimpleLogger
[src]
A macro for simulating env_logger behavior, which enables the user to choose log level by
setting a RUST_LOG
environment variable. The RUST_LOG
is not set or its value is not
recognized as one of the log levels, this function with use the Error
level by default.
You may use the various builder-style methods on this type to configure
the logger, and you must call init
in order to start logging messages.
use simple_logger::SimpleLogger; SimpleLogger::from_env().init().unwrap(); log::warn!("This is an example message.");
#[must_use = "You must call init() to begin logging"]pub fn with_level(self, level: LevelFilter) -> SimpleLogger
[src]
Set the ‘default’ log level.
You can override the default level for specific modules and their sub-modules using with_module_level
#[must_use = "You must call init() to begin logging"]pub fn with_module_level(self, target: &str, level: LevelFilter) -> SimpleLogger
[src]
Override the log level for some specific modules.
This sets the log level of a specific module and all its sub-modules. When both the level for a parent module as well as a child module are set, the more specific value is taken. If the log level for the same module is specified twice, the resulting log level is implementation defined.
Examples
Silence an overly verbose crate:
use simple_logger::SimpleLogger; use log::LevelFilter; SimpleLogger::new().with_module_level("chatty_dependency", LevelFilter::Warn).init().unwrap();
Disable logging for all dependencies:
use simple_logger::SimpleLogger; use log::LevelFilter; SimpleLogger::new() .with_level(LevelFilter::Off) .with_module_level("my_crate", LevelFilter::Info) .init() .unwrap();
#[must_use = "You must call init() to begin logging"]pub fn with_target_levels(
self,
target_levels: HashMap<String, LevelFilter>
) -> SimpleLogger
[src]
self,
target_levels: HashMap<String, LevelFilter>
) -> SimpleLogger
This is a leftover from before there was the builder pattern. Use with_module_level
instead.
Override the log level for specific targets.
pub fn init(self) -> Result<(), SetLoggerError>
[src]
‘Init’ the actual logger, instantiate it and configure it, this method MUST be called in order for the logger to be effective.
Trait Implementations
impl Default for SimpleLogger
[src]
impl Log for SimpleLogger
[src]
Auto Trait Implementations
impl RefUnwindSafe for SimpleLogger
impl Send for SimpleLogger
impl Sync for SimpleLogger
impl Unpin for SimpleLogger
impl UnwindSafe for SimpleLogger
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,