Skip to main content

Logger

Struct Logger 

Source
pub struct Logger<W: Write + Send> { /* private fields */ }
Expand description

Represents a logging object that writes to a specified output. It can be used simultaneously from multiple threads; it guarantees to serialize writes.

Use LoggerBuilder to construct a Logger, or use Logger::default().

Implementations§

Source§

impl<W: Write + Send> Logger<W>

Source

pub fn builder(w: W) -> LoggerBuilder<W>

Returns a LoggerBuilder that can be used to build a Logger.

Source

pub fn write_output( &self, level: Level, target: &str, file: Option<&str>, line: Option<u32>, s: &str, )

Writes the given string s using the logger. Typically, you would not use this directly but instead use the macros provided by the log crate.

Trait Implementations§

Source§

impl Default for Logger<Stderr>

Source§

fn default() -> Logger<Stderr>

Returns a default Logger.

A default Logger has

  • level: log::LevelFilter::Trace,
  • out: stderr,
  • flags: L_STD, and
  • prefix: "" (empty string)
Source§

impl<W: Write + Send> Log for Logger<W>

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
Source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
Source§

fn flush(&self)

Flushes any buffered records.

Auto Trait Implementations§

§

impl<W> !Freeze for Logger<W>

§

impl<W> RefUnwindSafe for Logger<W>

§

impl<W> Send for Logger<W>

§

impl<W> Sync for Logger<W>

§

impl<W> Unpin for Logger<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Logger<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for Logger<W>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.