-
Notifications
You must be signed in to change notification settings - Fork 384
use the log
crate + env_logger
#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b3a175f
4f3f202
49dfd82
f1e4ef6
f9a5416
b7df4fd
c62cce3
af41c54
fee3a2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ extern crate getopts; | |
extern crate miri; | ||
extern crate rustc; | ||
extern crate rustc_driver; | ||
extern crate env_logger; | ||
extern crate log_settings; | ||
extern crate log; | ||
|
||
use miri::interpreter; | ||
use rustc::session::Session; | ||
|
@@ -31,6 +34,27 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { | |
|
||
#[miri_run] | ||
fn main() { | ||
init_logger(); | ||
let args: Vec<String> = std::env::args().collect(); | ||
rustc_driver::run_compiler(&args, &mut MiriCompilerCalls); | ||
} | ||
|
||
#[miri_run] | ||
fn init_logger() { | ||
let format = |record: &log::LogRecord| { | ||
// prepend spaces to indent the final string | ||
let indentation = log_settings::settings().indentation; | ||
let spaces = " "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you were going for a max indentation here? It'd be nice to handle that in numbers rather than having this string which I'm not sure how long it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice if the indentation wrapped around to 0 when it gets too long with an indicator that it's actually extra-deep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense |
||
let indentation = &spaces[..std::cmp::min(indentation, spaces.len())]; | ||
format!("{} -{} {}", record.level(), indentation, record.args()) | ||
}; | ||
|
||
let mut builder = env_logger::LogBuilder::new(); | ||
builder.format(format).filter(None, log::LogLevelFilter::Info); | ||
|
||
if std::env::var("RUST_LOG").is_ok() { | ||
builder.parse(&std::env::var("RUST_LOG").unwrap()); | ||
} | ||
|
||
builder.init().unwrap(); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this to
indent_amount
or something so theindentation
later doesn't use the same name?EDIT: Err, they're both indentation amounts... scratch that. I guess you could move
% NSPACES
into the format call and remove the shadowing variable.