srlog

Crates.iosrlog
lib.rssrlog
version0.1.0
sourcesrc
created_at2023-12-15 21:34:02.758481
updated_at2023-12-15 21:34:02.758481
descriptionSimple logging with templating
homepagehttps://github.com/simalei/srlog
repositoryhttps://github.com/simalei/srlog
max_upload_size
id1071304
size7,234
Alexander Simonov (simalei)

documentation

README

srlog

Simple logging with templating

  • Disclaimer: srlog was created as an alternative to the spdlog in Rust. However, since I'm still a beginner, the code may be bad and so on. Any contribution or feature suggestion is much appreciated!

Examples

  • Basic usage

use srlog::logger::Logger;

fn main() {
    let mut logger = Logger::new();
    logger.debug("debug message");
    logger.info("info message");
    logger.warn("warning message");
    logger.error("error message");
}


  • Custom templates
use srlog::logger::Logger;

fn main() {
    let mut logger = Logger::new();
    logger.info("This is default template");
    logger.set_template("{level} {message}").expect("Failed to set template");
    logger.info("This is new template");
}

Supported keys

Key Output
level Level of the log message
message Message itself
hour Hour
day Day
month_num Month as a number
month_name Name of the month
year Year
time Time
date Date
Commit count: 3

cargo fmt