LumeLog
LumeLog is a lightweight, flexible, and configurable logging library for Rust. It supports different log levels, runtime configuration, and styled log outputs, making it suitable for both development and production environments.
Features
- Log Levels: Supports
ERROR
,WARN
,INFO
,DEBUG
, andTRACE
. - Styled Output: Provides color-coded logs for enhanced readability.
- File Logging: Optionally logs messages to a file in text or JSON format.
- Runtime Configuration: Configure logging behavior without recompiling.
- Build Mode Detection: Automatically adjusts logging for debug or release builds.
Installation
Add lumelog
to your Cargo.toml
:
[]
= "0.1.3"
Then, include it in your code:
use ;
Quick Start
Here’s a basic example to get started:
use ;
Configuration
You can customize LumeLog using the ConfigBuilder. Here’s what you can configure:
Log Levels
- ERROR
- WARN
- INFO
- DEBUG
- TRACE
Example:
let config = new
.log_level // Log all messages down to DEBUG
.build
.unwrap;
File Logging
Enable file logging and specify a path and format:
use ;
let config = new
.file_logger_config
.build
.unwrap;
Logging Macros
LumeLog provides easy-to-use macros for logging messages at various levels:
- info!: Logs informational messages.
- warn!: Logs warnings.
- error!: Logs errors.
- debug!: Logs debug messages.
- trace!: Logs trace-level messages.
Example:
info!;
warn!;
error!;
Full config struct settings
ConfigBuilder
Build Mode Detection
LumeLog automatically detects build mode (debug or release) and adjusts logging behavior accordingly. You can override this behavior using the log_in_release configuration.
!NOTE: If log_in_release
is enabled, trace and debug messages will not be logged.
License
LumeLog is dual-licensed under the MIT or Apache 2.0 license. See LICENSE-MIT or LICENSE-APACHE for details.