A simple, colorful, and flexible logging library for Rust with support for timestamps, log levels, and custom error codes. Built using a builder pattern for ergonomic usage.
- Four log levels:
Info
,Warn
,Error
,Debug
- Optional timestamps
- Optional custom error codes
- Color-coded output in the terminal
- Ergonomic builder pattern
Add code_logger
to your Cargo.toml
:
[dependencies]
code_logger = "..."
fn main() {
// Using builder
log("Hello, world!".to_string())
.timestamp()
.code(42)
.info() // builds the Logger
.print(); // actually prints it
// Or directly
let logger = log("Something went wrong".to_string())
.code(404)
.error(); // builds Logger
logger.print(); // prints it
}