errox

Crates.ioerrox
lib.rserrox
version0.1.1
sourcesrc
created_at2021-08-28 05:54:24.948658
updated_at2021-08-28 06:43:01.689478
descriptionA simple and minimal error logging library.
homepage
repositoryhttps://github.com/tduck973564/errox
max_upload_size
id443336
size47,363
Thomas (tduck973564)

documentation

https://docs.rs/errox

README

Errox

docs dependency status build status

A simple and minimal error logging library.

Errox is a minimal error logging library to log Err return types and print them to stderr, with an optional timestamp.

Examples

use errox::*; // This will use the default configuration.

fn return_err() -> Result<&'static str, &'static str> {
    Err("Error here")
}
fn return_ok() -> Result<&'static str, &'static str> {
    Ok("Nothing wrong!")
}
fn main() {
    return_err().error(); // Will print a message that looks like '[timestamp] error: Error here'
    return_err().warning(); // Will print a message that looks like '[timestamp] warning: Error here'
    return_ok().error(); // Won't output anything to stderr. 
}

Log leveling

Log leveling works by not showing any errors below the log level you have set. Log levels (in ascending order for priority) are as follows: Error Warning Info Debug Trace If you choose the warning log level, warnings and errors will be printed, while anything below warning will not be printed.

Writing a config file

To write a config file, you must make a file in the working directory of the binary with the name errox_config.toml. Options for the file are log_level (variant of log_level, shown above) and time (boolean), to toggle the timestamp.

Example

time = true
log_level = "Error"

Default configuration

The default configuration is loaded when no configuration file has been created.

time = true
log_level = "Trace"
Commit count: 0

cargo fmt