-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add an option to control whether timestamps are to be printed or not. #34
Conversation
println!( | ||
"{} {:<5} [{}] {}", | ||
Local::now().format("%Y-%m-%d %H:%M:%S,%3f"), | ||
level_string, | ||
target, | ||
record.args() | ||
); | ||
return; |
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.
out of curiosity: why the return;
instead of an else?
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.
To avoid duplicating the code for the two cases where there is no timestamp.
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.
Oh yes, forget the #[cfg(feature = "chrono")]
just above.
@@ -37,6 +41,7 @@ impl SimpleLogger { | |||
SimpleLogger { | |||
default_level: LevelFilter::Trace, | |||
module_levels: Vec::new(), | |||
timestamps: true |
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.
indent problem?
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.
Sorry about that, I guess I have to figure out how to convince the Rust mode to use spaces instead of tabs.
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.
Does cargo fmt
works for you?
Released in 1.12.0 with some changes (and a copy of this feature for colours, too). Thanks for your patience! |
Timestamps are useful when debugging, but when the program is executed from systemd, journald automatically adds timestamps to the lines, so one gets duplicate timestamps.
This adds an option to turn timestamps off without having to recompile with a different feature set.