Verified Commit f22e82b5 authored by Ole Martin Ruud's avatar Ole Martin Ruud
Browse files

Improve logformat for local package

parent de3ab452
......@@ -38,16 +38,24 @@ pub fn setup_logging(verbosity: usize, log_file: Option<File>) -> Result<(), fer
let stdout_config = fern::Dispatch::new()
.format(move |out, message, record| {
// special format for debug messages coming from our own crate.
if record.level() > log::LevelFilter::Info
&& record.target().starts_with(env!("CARGO_PKG_NAME"))
{
let is_local = record.target().starts_with(env!("CARGO_PKG_NAME"));
if record.level() > log::LevelFilter::Info && is_local {
// special format for debug messages coming from our own crate.
out.finish(format_args!(
"---\n{}: {}: {}\n---",
colors.color(record.level()),
chrono::Local::now().format("%H:%M:%S"),
message
))
} else if is_local {
// omit target when the log message is coming from our own app
out.finish(format_args!(
"[{}][{}] {}",
chrono::Local::now().format("%H:%M"),
colors.color(record.level()),
message
))
} else {
out.finish(format_args!(
"[{}][{}][{}] {}",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment