Struct Logger
pub struct Logger { /* private fields */ }
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.
Implementations
impl Logger
fn from_env<'a, E>(env: E) -> Self where 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 Logger; let logger = from_env;Create a logger using the
MY_LOGvariable for filtering andMY_LOG_STYLEfor whether or not to write styles:use ; let env = new.filter_or.write_style_or; let logger = from_env;fn from_default_env() -> SelfCreates 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 theEnvtype explicitly. The logger will use the default environment variables.Examples
Creates a logger using the default environment variables:
use Logger; let logger = from_default_env;fn filter(&self) -> LevelFilterReturns the maximum
LevelFilterthat this env logger instance is configured to output.fn matches(&self, record: &Record<'_>) -> boolChecks if this record matches the configured filter.
Trait Implementations
impl Debug for Logger
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Log for Logger
fn enabled(&self, metadata: &Metadata<'_>) -> boolfn log(&self, record: &Record<'_>)fn flush(&self)
Auto Trait Implementations
impl !RefUnwindSafe for Logger
impl !UnwindSafe for Logger
impl Freeze for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnsafeUnpin for Logger
Blanket Implementations
impl<T> Any for Logger
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Logger
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Logger
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Logger
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Logger
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Logger
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Logger
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>