Skip to content
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

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Conversation

andylokandy
Copy link
Contributor

No description provided.

@@ -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())?;
Copy link
Contributor

@tisonkun tisonkun Aug 2, 2024

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).

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it make sense

@@ -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())?;
Copy link
Contributor

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?

@andylokandy andylokandy changed the title chore: reduce one allocation in stdio append chore: rename MaxFilter to LevelFilter Aug 2, 2024
@andylokandy andylokandy enabled auto-merge (squash) August 2, 2024 06:22
@andylokandy andylokandy enabled auto-merge (squash) August 2, 2024 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants