-
Notifications
You must be signed in to change notification settings - Fork 7
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
chore: rename MaxFilter to LevelFilter #23
Conversation
src/append/stdio.rs
Outdated
@@ -36,8 +35,7 @@ pub struct Stderr; | |||
|
|||
impl Append for Stderr { | |||
fn append(&self, record: &log::Record) -> anyhow::Result<()> { | |||
let bytes = format!("{}\n", record.args()).into_bytes(); | |||
std::io::stderr().write_all(&bytes)?; | |||
writeln!(std::io::stderr(), "{}", record.args())?; |
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 don't check in details but IIRC fern has some related tricks to avoid deadlock in logging.
Check - https://docs.rs/fern/0.6.2/fern/meta/index.html
And @Xuanwo ever encountered similar situation (dead lock in fmt).
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.
And we only call format to alloc the string then write the bytes. IIRC it won't alloc twice?
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.
it make sense
src/append/stdio.rs
Outdated
@@ -36,8 +35,7 @@ pub struct Stderr; | |||
|
|||
impl Append for Stderr { | |||
fn append(&self, record: &log::Record) -> anyhow::Result<()> { | |||
let bytes = format!("{}\n", record.args()).into_bytes(); | |||
std::io::stderr().write_all(&bytes)?; | |||
writeln!(std::io::stderr(), "{}", record.args())?; |
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.
And we only call format to alloc the string then write the bytes. IIRC it won't alloc twice?
No description provided.