Struct Formatter
struct Formatter { ... }
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: &Self, level: Level) -> style::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 crate::fmt::Formatter
fn timestamp(self: &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: &Self) -> TimestampGet a
Timestampfor the current date and time in UTC with full second precision.fn timestamp_millis(self: &Self) -> TimestampGet a
Timestampfor the current date and time in UTC with millisecond precision.fn timestamp_micros(self: &Self) -> TimestampGet a
Timestampfor the current date and time in UTC with microsecond precision.fn timestamp_nanos(self: &Self) -> TimestampGet a
Timestampfor the current date and time in UTC with nanosecond precision.
impl Debug for Formatter
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Freeze for Formatter
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnwindSafe for Formatter
impl Write for Formatter
fn write(self: &mut Self, buf: &[u8]) -> io::Result<usize>fn flush(self: &mut Self) -> io::Result<()>
impl<T> Any for Formatter
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Formatter
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Formatter
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Formatter
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Formatter
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Formatter
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Formatter
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>