Expand description
A lightweight, flexible logging framework for Rust applications.
This crate provides a configurable logging system that supports multiple output targets, customizable formatting, and different log levels. It can be used in both synchronous (blocking) and asynchronous contexts.
§Features
- Multiple log levels (Debug, Info, Warning, Error)
- Multiple output targets (Console, File)
- Customizable log formatting
- Async and blocking implementations
§Example
ⓘ
use logger::{init, LogLevel};
// Initialize with Info level
init(LogLevel::Info);
// Log messages
info!("Application started");
debug!("This won't be displayed with Info level");
error!("Something went wrong: {}", error);Macros§
- debug
- Logs a message at the DEBUG level.
- error
- Logs a message at the ERROR level.
- fatal
- Logs a message at the FATAL level.
- info
- Logs a message at the INFO level.
- log
- Macro for logging messages at a specific level.
- trace
- Logs a message at the TRACE level.
- warn
- Logs a message at the WARN level.
Structs§
- Config
- Configuration for initializing a logger.
- Console
- Standard console output target.
- Default
Formatter - Default log message formatter.
- Default
Logger - File
- File output target.
- Record
- Represents a single log record with all relevant metadata.
Enums§
- Color
- ANSI color codes for terminal output.
- Error
- File
Mode - File open mode for writing log messages.
- Hook
- Represents a hook that can be set to trigger at specific points in the logging process.
- LogLevel
- Logging severity levels in ascending order of importance.
- Output
- Output destination for console log messages.
- Target
Id - Represents the id of the target where the log message is written. This can be a console output, file path, or a custom string identifier. Useful for identifying the target in hooks / filters.
Traits§
- Colorize
- Trait for applying colors to strings.
- Formatter
- Defines a log message formatter.
- Logger
- Core trait that defines the logging behavior.
- Style
- Target
- Defines an output destination for log messages.
Functions§
- init
- Initializes the global logger with the specified minimum log level.
- init_
default - Initializes the global logger with default settings.
- init_
with_ config - Initializes the global logger with a custom configuration.
- logger
- Retrieves the global logger instance.
- set_
hook - Sets a hook to be called at the specified point in the logging process.