#![allow(dead_code)]
mod custom_formatter;
mod custom_handler;
use flogging::*;
use custom_formatter::CustomFormatter;
use custom_handler::CustomHandler;
#[cfg(test)]
mod test {
use super::*;
#[test]
fn custom_handler() {
let mut log = Logger::custom_logger(
module_path!(),
"CustomHandler",
Box::new(CustomHandler::create("custom_handler").unwrap()),
);
log.info("Just testing");
let list = log
.get_handler(Handler::Custom("CustomHandler".to_string()))
.unwrap()
.as_ref()
.get_log();
println!("Log:\n{}", list);
assert_eq!(&list, "it_customs::test-> [INFO ] Just testing\n")
}
#[test]
fn add_console_handler_with_custom_formatter() {
let mut log = Logger::builder(module_path!())
.add_console_handler_with(
FormatType::Custom,
Some(Box::new(CustomFormatter::new())),
)
.build();
log.info("Testing custom formatter");
}
#[test]
fn add_econsole_handler_with_custom_formatter() {
let mut log = Logger::builder(module_path!())
.add_econsole_handler_with(
FormatType::Custom,
Some(Box::new(CustomFormatter::new())),
)
.build();
log.info("Testing custom formatter");
}
}