-
-
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(log): Helper implemented io.Writer #1927
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1927 +/- ##
==========================================
+ Coverage 80.65% 80.77% +0.11%
==========================================
Files 81 82 +1
Lines 3587 3635 +48
==========================================
+ Hits 2893 2936 +43
- Misses 487 492 +5
Partials 207 207
Continue to review full report at Codecov.
|
infoWriter := log.NewWriter(logger, log.LevelInfo, "log")
warnWriter := log.NewWriter(logger, log.LevelWarn, "log")
errorWriter := log.NewWriter(logger, log.LevelError, "log")
redis.SetLogger(log.New(infoWriter, "redis: ", log.LstdFlags|log.Lshortfile))
grpclog.SetLogger(grpclog.NewLoggerV2(infoWriter, warnWriter, errorWriter)) You can provide a log writer to output third-party logs |
Create and use a new function: |
Yes, you can create a Writer Helper to do this. |
Updated. |
* feat(log): Add writerWrapper implementing io.Writer * fix(kratos): fix format has wrong type * fix(log): rename writerOption to WriterOptionFn.
Implemented io.Writer, easy to use in standard library, like log.New.
Description (what this PR does / why we need it):
Helper
can set tohttp.Server{}.ErrorLog
.Example 1(transport/http):
Example 2 (go-redis):
Other special notes for reviewer: