pub struct Logger { /* private fields */ }
Expand description
A logger within the Artifact logging library. This struct is somewhat similar to an address. The struct itself only stores the name of the logger. However, the initialization functions tell the backend what kind of logger it is, what level it logs at, and other interesting information.
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn set_default_formatter(fmtr: Box<dyn MessageFormatter>)
pub fn set_default_formatter(fmtr: Box<dyn MessageFormatter>)
Sets the default formatter. This formatter will be used by any logger which does not have a formatter set for it.
Sourcepub fn access(name: &str) -> Logger
pub fn access(name: &str) -> Logger
Creates a Logger instance, but does not tell the backend to initialize the logger.
Sourcepub fn access_internal_logger() -> Logger
pub fn access_internal_logger() -> Logger
Accesses the Artifact library’s internal logger. This can be redirected or reformatted to cause the internal logger to log however you need. By default, the internal logger logs to stdout.
Sourcepub fn new(name: &str, ty: LoggerOutput) -> Logger
pub fn new(name: &str, ty: LoggerOutput) -> Logger
Creates a logger which will log to the given output. This tells the backend logger task to initialize the logger.
Sourcepub fn new_with_level(name: &str, ty: LoggerOutput, level: LogLevel) -> Logger
pub fn new_with_level(name: &str, ty: LoggerOutput, level: LogLevel) -> Logger
Creates a logger for the given output which logs messages at or above the given level. This also initializes the logger by telling the backend task.
Sourcepub fn redirect(&self, ty: LoggerOutput)
pub fn redirect(&self, ty: LoggerOutput)
Redirects a logger to a new output location. Returns the logger as well
Sourcepub fn redirect_set_level(&self, ty: LoggerOutput, level: LogLevel)
pub fn redirect_set_level(&self, ty: LoggerOutput, level: LogLevel)
Redirects a logger and changes its level Returns the logger
Sourcepub fn disable(self)
pub fn disable(self)
Prevents use of a logger name, and kills off any existing logger instances with that name
Sourcepub fn disable_without_logs(self)
pub fn disable_without_logs(self)
Prevents use of a logger name, kills off any existing loggers with that name, and disables logging info about that logger entirely.
Sourcepub fn set_as_default(&self)
pub fn set_as_default(&self)
Sets the default logger to be this logger.
Sourcepub fn set_as_silent_default(&self)
pub fn set_as_silent_default(&self)
Sets the default logger to be this logger, silently. This means that all logs to an unknown logger will be directed to this logger. However, no addition to the message will be made by this logger.
Sourcepub fn set_format(&self, formatter: Box<dyn MessageFormatter>)
pub fn set_format(&self, formatter: Box<dyn MessageFormatter>)
Sets the logger’s format
Sourcepub fn log(&self, level: LogLevel, message: &str)
pub fn log(&self, level: LogLevel, message: &str)
Creates a new log message. This just sends a message across the backend channel to the actual logger task.