-
Notifications
You must be signed in to change notification settings - Fork 13.3k
A few logging improvements #9664
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 all commits
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
pub fn foo<T>() { | ||
fn death() -> int { fail2!() } | ||
debug2!("{:?}", (||{ death() })()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:logging_right_crate.rs | ||
// xfail-fast | ||
// exec-env:RUST_LOG=logging-right-crate=debug | ||
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.
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. This was actually intentional. Before these changes the program would actually fail because the wrong crate name was used as the top-level name. I suppose that I could make this Right now I ask logging of this crate, and shouldn't get logging of the external crates, but the other way around I'd ask for logging of the external crate and make sure that logging of this crate didn't happen. 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. Oh, ok. Probably worth a comment to this effect so that someone trying to work out what the test is doing in a year isn't entirely confused? ;) 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. Comment added below. |
||
|
||
// This is a test for issue #3046 to make sure that when we monomorphize a | ||
// function from one crate to another the right top-level logging name is | ||
// preserved. | ||
// | ||
// It used to be the case that if logging were turned on for this crate, all | ||
// monomorphized functions from other crates had logging turned on (their | ||
// logging module names were all incorrect). This test ensures that this no | ||
// longer happens by enabling logging for *this* crate and then invoking a | ||
// function in an external crate which will fail when logging is enabled. | ||
|
||
extern mod logging_right_crate; | ||
|
||
fn main() { | ||
// this function fails if logging is turned on | ||
logging_right_crate::foo::<int>(); | ||
} |
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't we just remove the
_level
arg?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.
I'd rather not completely remove it. In theory we could do things like colorizing log message or something fun like that, but in general it seems like "this might be useful" for a future evolvement of a logging library, even if we're just not using it right now.
My main worry would be that this is a perfectly reasonable function to call directly (via some call chain with
format_args!
at the top), and it seems appropriate to take a level, and just unfortunate that we don't do anything with it just yet.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.
Agreed with @alexcrichton here. Based on the way logging happens, it would be very weird not to have a level argument, It's also strange that it's not being used yet.