-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: use writer directly in stdLogger. #3121
Conversation
A benchmark for it.
goos: darwin
goarch: arm64
pkg: github.com/go-kratos/kratos/v2/log
BenchmarkNew-10 13301796 75.79 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/go-kratos/kratos/v2/log 1.344s
goos: darwin
goarch: arm64
pkg: github.com/go-kratos/kratos/v2/log
BenchmarkOld-10 6942644 160.6 ns/op 32 B/op 1 allocs/op
PASS
ok github.com/go-kratos/kratos/v2/log 1.525s |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3121 +/- ##
==========================================
+ Coverage 81.62% 81.64% +0.01%
==========================================
Files 91 91
Lines 4163 4167 +4
==========================================
+ Hits 3398 3402 +4
Misses 587 587
Partials 178 178 ☔ View full report in Codecov by Sentry. |
@hawkingrei And could you help me to review this code too? This code removed unnecessary "log.Output" so it doubles the performance of stdLogger. |
Description (what this PR does / why we need it):
log.stdLogger use log.Logger internally, and disable all options such as prefix or log flags. log.stdLogger use l.log like a io.Writer. So I removed l.log, use io.Writer directly.
Code "stdLogger use log.Logger with no options":
kratos/log/std.go
Lines 20 to 21 in 08300d8
Code "stdLogger not use any format features of log.Logger":
kratos/log/std.go
Lines 39 to 43 in 08300d8
Which issue(s) this PR fixes (resolves / be part of):
Other special notes for the reviewers:
I did not add test for stdLogger.Close, because there is no way to call Close outside.