[][src]Struct simple_logger::SimpleLogger

pub struct SimpleLogger { /* fields omitted */ }

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();
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();
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.

#[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 specific module.

Examples

Change log level for specific crate:

use simple_logger::SimpleLogger;
use log::LevelFilter;

SimpleLogger::new().with_module_level("something", LevelFilter::Warn).init();

Disable logging for specific crate:

use simple_logger::SimpleLogger;
use log::LevelFilter;

SimpleLogger::new().with_module_level("something", LevelFilter::Off).init();

#[must_use = "You must call init() to begin logging"]pub fn with_target_levels(
    self,
    target_levels: HashMap<String, LevelFilter>
) -> SimpleLogger
[src]

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]

fn default() -> Self[src]

See this

impl Log for SimpleLogger[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.