Struct Formatter
pub struct Formatter { /* private fields */ }
A formatter to write logs into.
Formatter implements the standard Write trait for writing log records.
It also supports terminal styling using ANSI escape codes.
Examples
Use the writeln macro to format a log record.
An instance of a Formatter is passed to an env_logger format as buf:
use Write;
let mut builder = new;
builder.format;
Implementations
impl Formatter
fn default_level_style(&self, level: Level) -> StyleGet the default
style::Stylefor the given level.The style can be used to print other values besides the level.
See
stylefor how to adapt it to the styling crate of your choice
impl Formatter
fn timestamp(&self) -> TimestampGet a
Timestampfor the current date and time in UTC.Examples
Include the current timestamp with the log record:
use Write; let mut builder = new; builder.format;fn timestamp_seconds(&self) -> TimestampGet a
Timestampfor the current date and time in UTC with full second precision.fn timestamp_millis(&self) -> TimestampGet a
Timestampfor the current date and time in UTC with millisecond precision.fn timestamp_micros(&self) -> TimestampGet a
Timestampfor the current date and time in UTC with microsecond precision.fn timestamp_nanos(&self) -> TimestampGet a
Timestampfor the current date and time in UTC with nanosecond precision.
Trait Implementations
impl Debug for Formatter
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Write for Formatter
fn write(&mut self, buf: &[u8]) -> Result<usize>fn flush(&mut self) -> Result<()>
Auto Trait Implementations
impl !RefUnwindSafe for Formatter
impl !Send for Formatter
impl !Sync for Formatter
impl !UnwindSafe for Formatter
impl Freeze for Formatter
impl Unpin for Formatter
impl UnsafeUnpin for Formatter
Blanket Implementations
impl<T> Any for Formatter
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Formatter
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Formatter
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Formatter
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Formatter
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 Formatter
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Formatter
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>