pub struct Logger {
pub src: String,
pub level: LevelFilter,
pub sink: Weak<LogSink>,
/* private fields */
}
Expand description
Sends log entries to a LogSink
.
Fields§
§src: String
Source of the log entries from this logger.
This could be the module name, the application name, or any other string to categorize log entries on.
level: LevelFilter
Maximum level of entries sent to the LogSink
.
Set to LevelFilter::Off
to not send any entries.
sink: Weak<LogSink>
Sink to send entries to.
Implementations§
source§impl Logger
impl Logger
sourcepub fn new(sink: &Arc<LogSink>) -> Logger
pub fn new(sink: &Arc<LogSink>) -> Logger
Creates a new Logger
for the given LogSink
.
The logger’s level
will initially be set to the default level of the
sink. The level can be changed to override the default.
sourcepub fn with_src(&self, src: impl Into<String>) -> Self
pub fn with_src(&self, src: impl Into<String>) -> Self
Creates a new Logger
with the same sink
and level
but with a new
src
.
sourcepub fn make_global(self) -> Result<(), MakeGlobalError>
pub fn make_global(self) -> Result<(), MakeGlobalError>
Sets this logger as the logging implementation for the standard log
crate.
sourcepub fn log(&mut self, level: Level, msg: &str) -> ContextWriter<'_>
pub fn log(&mut self, level: Level, msg: &str) -> ContextWriter<'_>
Logs a message, with optional context, and sends it to the LogSink
.
sourcepub fn trace(&mut self, msg: &str) -> ContextWriter<'_>
pub fn trace(&mut self, msg: &str) -> ContextWriter<'_>
Logs a Trace
level message with optional context.
sourcepub fn debug(&mut self, msg: &str) -> ContextWriter<'_>
pub fn debug(&mut self, msg: &str) -> ContextWriter<'_>
Logs a Debug
level message with optional context.
sourcepub fn info(&mut self, msg: &str) -> ContextWriter<'_>
pub fn info(&mut self, msg: &str) -> ContextWriter<'_>
Logs an Info
level message with optional context.
sourcepub fn warn(&mut self, msg: &str) -> ContextWriter<'_>
pub fn warn(&mut self, msg: &str) -> ContextWriter<'_>
Logs a Warn
level message with optional context.
sourcepub fn error(&mut self, msg: &str) -> ContextWriter<'_>
pub fn error(&mut self, msg: &str) -> ContextWriter<'_>
Logs an Error
level message with optional context.