[−][src]Struct env_logger::Logger
The env logger.
This struct implements the Log
trait from the log
crate,
which allows it to act as a logger.
The init()
, try_init()
, Builder::init()
and Builder::try_init()
methods will each construct a Logger
and immediately initialize it as the
default global logger.
If you'd instead need access to the constructed Logger
, you can use
the associated Builder
and install it with the
log
crate directly.
Methods
impl Logger
[src]
pub fn from_env<'a, E>(env: E) -> Self where
E: Into<Env<'a>>,
[src]
E: Into<Env<'a>>,
Creates the logger from the environment.
The variables used to read configuration from can be tweaked before passing in.
Examples
Create a logger reading the log filter from an environment variable
called MY_LOG
:
use env_logger::Logger; let logger = Logger::from_env("MY_LOG");
Create a logger using the MY_LOG
variable for filtering and
MY_LOG_STYLE
for whether or not to write styles:
use env_logger::{Logger, Env}; let env = Env::new().filter_or("MY_LOG", "info").write_style_or("MY_LOG_STYLE", "always"); let logger = Logger::from_env(env);
pub fn from_default_env() -> Self
[src]
Creates the logger from the environment using default variable names.
This method is a convenient way to call from_env(Env::default())
without
having to use the Env
type explicitly. The logger will use the
default environment variables.
Examples
Creates a logger using the default environment variables:
use env_logger::Logger; let logger = Logger::from_default_env();
pub fn filter(&self) -> LevelFilter
[src]
Returns the maximum LevelFilter
that this env logger instance is
configured to output.
pub fn matches(&self, record: &Record) -> bool
[src]
Checks if this record matches the configured filter.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,