Logfather
A simple, lightweight, and easy-to-use logging system. It allows for detailed log messages, configurable output levels, and supports both file and terminal output.
Features
- Easy to set up and use
- Supports logging to both the terminal and log files
- Customizable log message format
- Configurable log levels (Info, Debug, Warning, Error, Critical, and Diagnostic)
- Configurable level display including colors, highlights, and styles
- Optional result (prepend
r_) macros for managed errors - Thread-safe
Getting Started
To start using Logfather, add the following to your Cargo.toml:
[]
= "0.2.6"
- Minimum supported Rust version:
1.61.0 - Check out crates.io
- All the information you'll need in the Documentation
Usage
Macros:
- Trace:
trace!()orr_trace!() - Debug:
debug!()orr_debug!() - Info:
info!()orr_info!() - Warning:
warn!(),warning!(),r_warn!(), orr_warning!() - Error:
error!()orr_error!() - Critical:
critical!(),crit!(),r_critical!(), orr_crit!() - Diagnostic:
diagnostic!(),diag!(),r_diagnostic!(), orr_diag!()
Quick setup for outputting to terminal:
use *;
let mut logger = new; //Terminal output is enabled by default
error!;
Setting up for only file output with specific error levels to be written:
use *;
let mut logger = new;
logger.terminal; // Disable terminal output
logger.file; // Enable file output
logger.path; // Set the path for file logging
logger.level; // Set the minimum level
info!; // Will not be written to file
debug!; // Will not be written to file
warning!; // Will not be written to file
error!; // Will be written to file
critical!; // Will be written to file
Set up for both terminal and file output capturing every level except warning
use *;
// Supports the builder pattern
let mut logger = new // Terminal output is enabled by default
.file // Enable file output
.path // Set the path for file logging
.ignore; // Set the specific level to ignore
debug!;
warning!; // Will be ignored
critical!;
Handle erroneous values gracefully with the r_ prepended macros
use *;
let mut logger = new;
match r_info!
Debug and Diagnostic levels are Debug build only and will not be compiled in release builds
use *;
debug!;
diag!;
diagnostic!;
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
._. why would you do this?
- Please open an issue with [FEATURE REQUEST] in the title if you wish to
- If you wish to contribute, issues and feature requests are a great way to do so. If you wish to fork and open a PR with changes, please provide information on what is being changed in great detail. This is my own pet project, so I will be opinionated, but I'm not against improvements or suggestions for improvements.