use chrono;
use fern;
use log;
use std::io;
pub const MODULE_NAME: &str = "oysterpack_app_metadata";
fn init_logging() -> Result<(), fern::InitError> {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{}[{}][{}] {}",
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S%.6f]"),
record.level(),
record.target(),
message
))
}).level(log::LevelFilter::Warn)
.level_for(MODULE_NAME, log::LevelFilter::Debug)
.chain(io::stdout())
.apply()?;
Ok(())
}
lazy_static! {
pub static ref INIT_FERN: Result<(), fern::InitError> = init_logging();
}
pub fn run_test<F: FnOnce() -> ()>(test: F) {
let _ = *INIT_FERN;
test()
}
#[test]
fn compiles() {
run_test(|| {
info!("it compiles :)");
use std::{env, path};
let doc_dir = path::Path::new(&env::var("OUT_DIR").unwrap())
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("doc")
.join(env!("CARGO_PKG_NAME"));
info!("doc_dir: {}", doc_dir.to_str().unwrap());
});
}