Struct simple_logging::SimpleLogger
[−]
[src]
pub struct SimpleLogger<T: Write> { /* fields omitted */ }
A simple logger for the log
facade.
Each and every log message obeys the following fixed and easily-parsable format:
[<hh>:<mm>:<ss>.<SSS>] (<thread-id>) <level> <message>\n
Where <hh>
denotes hours zero-padded to at least two digits, <mm>
denotes minutes zero-padded to two digits, <ss>
denotes seconds
zero-padded to two digits and <SSS>
denotes miliseconds zero-padded to
three digits. <thread-id>
is an implementation-specific alphanumeric ID.
<level>
is the log level as defined by log::LogLevel
and padded right
with spaces. <message>
is the log message. Note that <message>
is
written to the log as-is, including any embedded newlines.
Examples
SimpleLogger
implements
log::Log
, and as such may
be used with
log::set_logger
directly:
use log::LogLevelFilter; use simple_logging::SimpleLogger; use std::io; log::set_logger(|max_log_level| { max_log_level.set(LogLevelFilter::Info); Box::new(SimpleLogger::new(io::sink())) });
However, because this is the expected way to use SimpleLogger
, there is a
shorthand function for the operation above: log_to()
.
Errors
Any errors returned by the sink when writing are ignored.
See also
Methods
impl<T: Write> SimpleLogger<T>
[src]
fn new(sink: T) -> Self
Create a new SimpleLogger
.