youlog 0.1.2

A logging crate where you bring your own logging logic
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented1 out of 10 items with examples
  • Size
  • Source code size: 33.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.56 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • sometimes-youwin/youlog
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • you-win

youlog

A thin logging implementation for Rust's log facade.

This crate allows for providing custom functions to the logger.

Examples where this might be useful:

  • Logging logic needs to be different across log levels
  • Another application's logger is being used like with godot-rust
  • An existing crate is too opinionated in how it handles logging

Features

  • Setting logging functions per log level
  • Setting a logging function across all log levels
  • Filtering logs per module/filter
  • Initializing filters from an environment variable (RUST_LOG by default)

Example

use log::LevelFilter;
use youlog::Youlog;

Youlog::new()
    .global_level(LevelFilter::Info)
    .log_fn(LevelFilter::Info, |record| {
        println!("info {}", record.args().as_str().unwrap_or_default());
    })
    .raw_fn(|record| {
        println!("raw {}", record.args().as_str().unwrap_or_default());
    })
    .level("some_module", LevelFilter::Error)
    .init()
    .expect("unable to init logger");

log::info!("this is an info log!");

License

MPL-2.0

Filter implementation referenced from env_logger.