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

Logger: add Log method #1118

Merged
merged 3 commits into from Jun 22, 2022
Merged

Logger: add Log method #1118

merged 3 commits into from Jun 22, 2022

Conversation

craigpastro
Copy link
Contributor

Unfortunately I don't see how this could be used internally without breaking caller skip.

Resolve #1084.

@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #1118 (e25b3df) into master (c58bc94) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1118      +/-   ##
==========================================
- Coverage   98.36%   98.32%   -0.05%     
==========================================
  Files          49       49              
  Lines        2145     2147       +2     
==========================================
+ Hits         2110     2111       +1     
- Misses         27       28       +1     
  Partials        8        8              
Impacted Files Coverage Δ
logger.go 96.66% <100.00%> (+0.05%) ⬆️
zapcore/entry.go 92.77% <0.00%> (-1.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c58bc94...e25b3df. Read the comment docs.

sugar.go Outdated
if ce := s.base.Check(lvl, msg); ce != nil {
ce.Write(s.sweetenFields(context)...)
}
s.base.Log(lvl, msg, s.sweetenFields(context)...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would revert this and the other change in this file.

The Check version has the advantage that we don't spend CPU on sweetenFields unless we're actually going to log the message. So if the log level is too low or the message gets sampled, we won't pay to serialize the fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that is a good point. Thank you! Reverted.

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

Unfortunately I don't see how this could be used internally without breaking caller skip.

Yeah, fair. I don't see an obvious way to do that without some refactoring.
This should be fine as-is.

CC @sywhang @mway

@abhinav abhinav merged commit 78c80fb into uber-go:master Jun 22, 2022
@abhinav
Copy link
Collaborator

abhinav commented Jun 22, 2022

Thanks!

@craigpastro craigpastro deleted the add-log branch June 22, 2022 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Specify log level by parameter
3 participants