sw-logger-rs

Crates.iosw-logger-rs
lib.rssw-logger-rs
version1.1.2
sourcesrc
created_at2024-02-21 10:39:01.444353
updated_at2024-02-21 11:26:48.151252
descriptionSimple logger for Rust
homepagehttps://github.com/Subwoof01/sw-logger-rs
repositoryhttps://github.com/Subwoof01/sw-logger-rs
max_upload_size
id1147835
size13,201
Jordan Klop (Subwoof01)

documentation

README

A simple Rust logger.

Usage

To log messages, first set up the default path and log level like so:

fn main() {
    sw_logger_rs::set_path("/path/to/logfile.log");
    sw_logger_rs::set_level(sw_logger_rs::LogLevel::Debug);
}

If logging to a file is not necessary, simply set the path to an empty string, like so:

sw_logger_rs::set_path("");

Then to log messages, call the log() function:

use sw_logger_rs::*;

fn main() {
    sw_logger_rs::set_path("/path/to/logfile.log");
    sw_logger_rs::set_level(LogLevel::Debug);

    log("This is a logged message!", LogType::Warning, None);
}

For clarity, opt to explicitly state the package name when calling set_path() and set_level().

To write the message to a different path than the default, change the None parameter to Some("/custom/path/here").

Commit count: 0

cargo fmt