Simplify logging output.

This commit is contained in:
Scott Olson 2017-02-07 00:45:22 -08:00
parent 0afcb0568e
commit a5b9a0cb78

View File

@ -143,24 +143,25 @@ fn resource_limits_from_attributes(state: &CompileState) -> miri::ResourceLimits
} }
fn init_logger() { fn init_logger() {
const MAX_INDENT: usize = 40;
let format = |record: &log::LogRecord| { let format = |record: &log::LogRecord| {
if record.level() == log::LogLevel::Trace { if record.level() == log::LogLevel::Trace {
// prepend spaces to indent the final string // prepend spaces to indent the final string
let indentation = log_settings::settings().indentation; let indentation = log_settings::settings().indentation;
format!("{lvl}:{module}{depth:2}{indent:<indentation$} {text}", format!(
"{lvl}:{module}:{indent:<indentation$} {text}",
lvl = record.level(), lvl = record.level(),
module = record.location().module_path(), module = record.location().module_path(),
depth = indentation / MAX_INDENT, indentation = indentation,
indentation = indentation % MAX_INDENT,
indent = "", indent = "",
text = record.args()) text = record.args(),
)
} else { } else {
format!("{lvl}:{module}: {text}", format!(
"{lvl}:{module}: {text}",
lvl = record.level(), lvl = record.level(),
module = record.location().module_path(), module = record.location().module_path(),
text = record.args()) text = record.args(),
)
} }
}; };