Crate r3bl_simple_logger
source ·Expand description
How to log things, and simply use the logging facilities
The simplest way to use this crate is to look at the
r3bl_rs_utils_core::try_to_set_log_level
function in the r3bl_rs_utils_core
crate as the main entry point. By default,
logging is disabled even if you call all the functions in the file_logger
module in
that crate: log_debug
, log_info
, log_trace
, etc.
How to change how logging is implemented under the hood
Under the hood the simplelog
crate is forked
and modified for use here. The following are details for people who want to work on
changing the underlying behavior of the logging engine itself, and not for folks who
just want to use this crate.
r3bl_simple_logger
provides a series of logging facilities, that can be easily combined.
SimpleLogger
(very basic logger that logs to stdout)TermLogger
(advanced terminal logger, that splits to stdout/err and has color support) (can be excluded on unsupported platforms)WriteLogger
(logs to a given struct implementingWrite
, e.g. a file)CombinedLogger
(can be used to form combinations of the above loggers)TestLogger
(specialized logger for tests. Uses print!() / println!() for tests to be able to capture the output)
Only one Logger should be initialized of the start of your program
through the Logger::init(...)
method. For the actual calling syntax
take a look at the documentation of the specific implementation(s) you wanna use.
Macros
- Logs a message at the debug level.
- Logs a message at the error level.
- Logs a message at the info level.
- The standard logging macro.
- Determines if a message logged at the specified level in that module will be logged.
- Logs a message at the trace level.
- Logs a message at the warn level.
Structs
- The CombinedLogger struct. Provides a Logger implementation that proxies multiple Loggers as one.
- Configuration for the Loggers
- Builder for the Logger Configurations (
Config
) - Metadata about a log message.
- Builder for
Metadata
. - The type returned by
from_str
when the string doesn’t match any of the log levels. - The “payload” of a log message.
- Builder for
Record
. - The type returned by
set_logger
ifset_logger
has already been called. - The SimpleLogger struct. Provides a very basic Logger implementation
- The TermLogger struct. Provides a stderr/out based Logger implementation
- The TestLogger struct. Provides a very basic Logger implementation that may be captured by cargo.
- The WriteLogger struct. Provides a Logger implementation for structs implementing
Write
, e.g. File
Enums
- The set of available colors for the terminal foreground/background.
- ColorChoice represents the color preferences of an end user.
- A complete description of how to format and parse a type.
- An enum representing the available verbosity levels of the logger.
- An enum representing the available verbosity level filters of the logger.
- Padding to be used for logging the level
- Padding to be used for logging the thread id/name
- Specifies which streams should be used when logging
- Mode for logging the thread name or id or both.
- Padding to be used for logging the thread id/name
Constants
- The statically resolved maximum log level.
Traits
- A trait encapsulating the operations required of a logger.
- Trait to have a common interface to obtain the Level of Loggers
Functions
- Returns a reference to the logger.
- Returns the current maximum log level.
- Sets the global logger to a
Box<Log>
. - Sets the global logger to a
&'static Log
. - A thread-unsafe version of
set_logger
. - Sets the global maximum log level.
- A thread-unsafe version of
set_max_level
.