Skip to content

Commit

Permalink
use format! compile time magics for indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 1, 2016
1 parent c62cce3 commit af41c54
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ fn main() {

#[miri_run]
fn init_logger() {
const NSPACES: usize = 40;
let format = |record: &log::LogRecord| {
// prepend spaces to indent the final string
let indentation = log_settings::settings().indentation;
let spaces = " ";
let depth = indentation / spaces.len();
let indentation = indentation % spaces.len();
let indentation = &spaces[..indentation];
format!("{}:{}{:2}{} {}", record.level(), record.location().module_path(), depth, indentation, record.args())
let depth = indentation / NSPACES;
let indentation = indentation % NSPACES;
format!("{lvl}:{module}{depth:2}{indent:<indentation$}{text}",
lvl = record.level(),
module = record.location().module_path(),
depth = depth,
indentation = indentation,
indent = "",
text = record.args())
};

let mut builder = env_logger::LogBuilder::new();
Expand Down

0 comments on commit af41c54

Please sign in to comment.