mutex_logger 1.0.0

a crate for a logger that usess mutex for thread safty
Documentation
  • Coverage
  • 57.89%
    11 out of 19 items documented0 out of 12 items with examples
  • Size
  • Source code size: 16.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.86 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • LiorBuch

Mutex Logger

A Rust logging crate designed for multithreaded environments. MLogger uses mutex guards to ensure thread-safe logging, preventing data races when logging from multiple threads concurrently.

Features

  • Thread-Safe Logging: Uses Mutex to protect internal data structures, making it safe to log from multiple threads.
  • Configurable Verbosity Levels: Control which logs are shown based on their severity level (e.g., Error, Warn, Info, Debug).
  • Log Retention: Set a maximum number of log entries to keep, automatically discarding the oldest logs when the limit is reached.
  • Flexible API: Easily log messages, retrieve logs, and print logs at different verbosity levels.

Verbosity Levels

MLogger supports different verbosity levels to control which logs are displayed:

  • Silent: No logs are shown.
  • Error: Only error-level logs are shown.
  • Warn: Warning and error-level logs are shown.
  • Info: Information, warning, and error-level logs are shown.
  • Debug: All logs are shown, including debug-level logs.

Example


    let logger = Logger::init(Verbosity::Warn, 100);
    logger.log("this is error log!", Verbosity::Error).unwrap();
    logger.log("this is info log! it will not show!", Verbosity::Info).unwrap();
    println!("{}",logger.get_size().unwrap());

Change Log 1.0.0

  • Added color to the formated text.
  • Change the format text to show log id,colored verbosity,text.