Skip to content

Consolidate logging into a single println!() #2064

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

Merged
merged 2 commits into from
Dec 31, 2019

Conversation

jtgeibel
Copy link
Member

In production I observed serveral log lines with only " SLOW REQUEST".
Occasionally another thread will obtain the lock on stdout between our
calls to print!().

This implementation consolidates the entire log line into a single
println!() and avoids an allocation unless an error is being logged.

r? @smarnach

In production I observed serveral log lines with only " SLOW REQUEST".
Occasionally another thread will obtain the lock on stdout between our
calls to `print!()`.

This implementation consolidates the entire log line into a single
`println!()` and avoids an allocation unless an error is being logged.
The call to `to_string()` results in an unnecessary allocation.  `Error`
only implements `ToString` through the `Display` trait.  The same
formatting logic is used, but calling `to_string()` causes an additional
heap allocation.
@carols10cents
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 31, 2019

📌 Commit e8dd729 has been approved by carols10cents

@bors
Copy link
Contributor

bors commented Dec 31, 2019

⌛ Testing commit e8dd729 with merge 8cdaa9b...

bors added a commit that referenced this pull request Dec 31, 2019
Consolidate logging into a single `println!()`

In production I observed serveral log lines with only " SLOW REQUEST".
Occasionally another thread will obtain the lock on stdout between our
calls to `print!()`.

This implementation consolidates the entire log line into a single
`println!()` and avoids an allocation unless an error is being logged.

r? @smarnach
@bors
Copy link
Contributor

bors commented Dec 31, 2019

☀️ Test successful - checks-travis
Approved by: carols10cents
Pushing 8cdaa9b to master...

@bors bors merged commit e8dd729 into rust-lang:master Dec 31, 2019
@jtgeibel jtgeibel deleted the prod/interlaced-logs branch January 3, 2020 02:05
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.

6 participants