| Crates.io | logfather |
| lib.rs | logfather |
| version | 0.2.6 |
| created_at | 2024-01-06 00:44:57.549407+00 |
| updated_at | 2024-04-24 07:09:46.983865+00 |
| description | A simple and straightforward logging library for Rust. |
| homepage | |
| repository | https://github.com/JoshBenn/logfather |
| max_upload_size | |
| id | 1090630 |
| size | 61,557 |
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.
r_) macros for managed errorsTo start using Logfather, add the following to your Cargo.toml:
[dependencies]
logfather = "0.2.6"
1.61.0Macros:
trace!() or r_trace!()debug!() or r_debug!()info!() or r_info!()warn!(), warning!(), r_warn!(), or r_warning!()error!() or r_error!()critical!(), crit!(), r_critical!(), or r_crit!()diagnostic!(), diag!(), r_diagnostic!(), or r_diag!()Quick setup for outputting to terminal:
use logfather::*;
let mut logger = Logger::new(); //Terminal output is enabled by default
error!("This is an error message");
Setting up for only file output with specific error levels to be written:
use logfather::*;
let mut logger = Logger::new();
logger.terminal(false); // Disable terminal output
logger.file(true); // Enable file output
logger.path("log.txt"); // Set the path for file logging
logger.level(Level::Error); // Set the minimum level
info!("This is an info message"); // Will not be written to file
debug!("This is a debug message"); // Will not be written to file
warning!("This is a warning message"); // Will not be written to file
error!("This is an error message"); // Will be written to file
critical!("This is a critical message"); // Will be written to file
Set up for both terminal and file output capturing every level except warning
use logfather::*;
// Supports the builder pattern
let mut logger = Logger::new() // Terminal output is enabled by default
.file(true) // Enable file output
.path("log.txt") // Set the path for file logging
.ignore(Level::Warning); // Set the specific level to ignore
debug!("This is a debug message");
warning!("This is a warning message"); // Will be ignored
critical!("This is a critical message");
Handle erroneous values gracefully with the r_ prepended macros
use logfather::*;
let mut logger = Logger::new();
match r_info!("This will return a Result<(), LogfatherError>") {
Ok(_) => println!("Successfully logged output"),
Err(e) => println!("Error logging output: {e}"),
}
Debug and Diagnostic levels are Debug build only and will not be compiled in release builds
use logfather::*;
debug!("This is a debug message");
diag!("This is a diagnostic message");
diagnostic!("This will not output for release builds");
This project is licensed under the MIT License - see the LICENSE file for details.
._. why would you do this?