-
Notifications
You must be signed in to change notification settings - Fork 1.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
Added zapcore.TimeEncoderOfLayout #629
Conversation
Codecov Report
@@ Coverage Diff @@
## master #629 +/- ##
==========================================
+ Coverage 98.33% 98.35% +0.01%
==========================================
Files 43 43
Lines 2349 2366 +17
==========================================
+ Hits 2310 2327 +17
Misses 32 32
Partials 7 7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best format to pass arguments, but I like the general idea.
Thoughts @abhinav?
Actually I'm wondering which word to use, "format" or "layout"... |
Good question, since Go tends to use the word layout for the argument, it makes sense to use that in the YAML config. |
Don't know why codecov fails... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, thanks @tmshn!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, @abhinav does this look OK to you as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides minor comments. Thanks!
abbrev should be UPPERCASE Co-authored-by: Abhinav Gupta <[email protected]>
I added `zapcore.TimeEncoderOfFormat` to make it easy to build `TimeEncoder` of custom format. You can use it in code: ```go config := zap.NewDevelopmentConfig() config.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout("06/01/02 03:04pm") ``` or, with JSON: ```json { "encoderConfig": { "timeEncoder": { "layout": "06/01/02 03:04pm" } } } ``` or, with YAML: ```yaml encoderConfig: timeEncoder: layout: '06/01/02 03:04pm' ```
I added
zapcore.TimeEncoderOfFormat
to make it easy to buildTimeEncoder
of custom format.You can use it in code:
or, with JSON:
or, with YAML: