Crates.io | basic_log |
lib.rs | basic_log |
version | 0.2.0 |
source | src |
created_at | 2021-06-28 21:00:01.460642 |
updated_at | 2021-06-29 21:14:03.928634 |
description | A basic logging crate for Rust. |
homepage | https://github.com/mxrr/basic_log |
repository | https://github.com/mxrr/basic_log |
max_upload_size | |
id | 415909 |
size | 28,234 |
Focuses on having sensible defaults for basic logging to accomplish great out of the box functionality.
To use the default settings, simply create and initialise the logger
The crate exposes the logging macros provided by log for easy access
use basic_log::{BasicLog, info, warn, error};
fn main() {
BasicLog::new()
.init()
.expect("Failed to initialise BasicLog");
info!("Example info message");
warn!("Example warning");
error!("Example error");
}
To change logger behaviour you can use a closure or a settings struct
use basic_log::{BasicLog, trace, debug};
fn main() {
BasicLog::new_with_settings(
|s|
s
.enable_debug()
.enable_trace()
)
.init()
.expect("Failed to initialise BasicLog");
trace!("Example trace message");
debug!("Example debug message");
}
use basic_log::{BasicLog, LoggerSettings, trace, debug};
fn main() {
let log_settings = LoggerSettings::new()
.enable_debug()
.enable_trace();
BasicLog::new_with_struct(log_settings)
.init()
.expect("Failed to initialise BasicLog");
trace!("Example trace message");
debug!("Example debug message");
}