Expand description
§Loggit
Loggit is a lightweight logging library for Rust that provides built‑in logger macros
(such as trace!, debug!, info!, warn!, and error!) to allow you to start logging
with zero boilerplate. You can also customize the log level, format, colors, and output destination.
§Features
- Zero Setup: Just import the library and start logging.
- Customizable: Change log formats, colors, and logging levels.
- Macros Provided: Includes
trace!,debug!,info!,warn!, anderror!. - Flexible Formatting: Use custom templates with placeholders like
{level},{file},{line}, and{message}. - Saving log to files: Save your logs to files automaticaly by specifying filename format
- File rotation: Rotate your files by specifying time period or size
- Compress used files: Save your space by compressing used log files
§Installation
Add the following to your Cargo.toml:
[dependencies]
loggit = "0.1.1"Or use:
cargo add loggit§Usage Example
use loggit::{logger::init, trace, debug, info, warn, error, logger::set_log_level, Level};
fn main() {
// Optionally set a custom log level.
set_log_level(Level::DEBUG);
trace!("This is a trace message.");
debug!("Debug message: value = {}", 42);
info!("Informational message.");
warn!("Warning: check configuration!");
error!("Error occurred: {}", "example error");
}§Modules
logger: Contains functions to control logging configuration and macros to log messages.
Modules§
- logger
- The logger module provides configuration functions and macros for logging.
Macros§
- debug
- Logs a message at the DEBUG level. The message is formatted using standard Rust formatting.
- error
- Logs a message at the ERROR level. The message is formatted using standard Rust formatting.
- info
- Logs a message at the INFO level. The message is formatted using standard Rust formatting.
- trace
- Logs a message at the TRACE level. The message is formatted using standard Rust formatting.
- warn
- Logs a message at the WARN level. The message is formatted using standard Rust formatting.
Enums§
- Level
- Represents the log level used throughout the application.