Crates.io | errox |
lib.rs | errox |
version | 0.1.1 |
source | src |
created_at | 2021-08-28 05:54:24.948658 |
updated_at | 2021-08-28 06:43:01.689478 |
description | A simple and minimal error logging library. |
homepage | |
repository | https://github.com/tduck973564/errox |
max_upload_size | |
id | 443336 |
size | 47,363 |
Errox is a minimal error logging library to log Err return types and print them to stderr, with an optional timestamp.
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 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.
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.
time = true
log_level = "Error"
The default configuration is loaded when no configuration file has been created.
time = true
log_level = "Trace"