-
Notifications
You must be signed in to change notification settings - Fork 85
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
Use ISO8601 timestamp format for zap log messages #843
Use ISO8601 timestamp format for zap log messages #843
Conversation
Hi @creydr. Thanks for your PR. I'm waiting for a nmstate member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hello @creydr , thanks for your PR. Why not define a configuration with the said Something like this might work, of course ideally wrapped in a function and not directly in
|
0e6ffe1
to
e6e557d
Compare
Hello @rhrazdil, |
e6e557d
to
16050fb
Compare
/ok-to-test |
main.go
Outdated
@@ -252,6 +250,24 @@ func main() { | |||
} | |||
} | |||
|
|||
func setupLogger() { |
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.
Could you please make the setupLogger function more focused?
It's currently doing two things: setting up the logger, and parsing command line flags.
Maybe you could pass the opts as a parameter and do the flag parsing in main directly?
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.
Thanks for your feedback. Makes sense. I updated the PR.
16050fb
to
479d001
Compare
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.
Thanks! Just one small thing, wouldn't you mind squashing the two commits into one commit enriched by a brief description of the change?
main.go
Outdated
pflag.Parse() | ||
|
||
if logType == "debug" { | ||
// workarround until --v flag got removed |
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.
nit: workaround
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.
🤦 Thanks. Updated it
Adds the zap flagset to configure the logging. This includes the following flags: zap-devel: Enable zap development mode (changes defaults to console encoder, debug log level, disables sampling and stacktrace from warning level). zap-encoder: Zap log encoding (json or console). zap-level: Zap log level (one of debug, info, error or any uint value). zap-stacktrace-level: Set the minimum log level that triggers stacktrace generation. Deprecates the --v flag in favor of --zap-debug. Signed-off-by: Christoph Stäbler <cstabler@redhat.com>
Uses the ISO8601 format for encoding of log timestamps for a more human-readable output. Signed-off-by: Christoph Stäbler <cstabler@redhat.com>
479d001
to
7fb2914
Compare
If this is the usual way you do it here I can squash them. Anyhow I kept them separate as they are 2 different changes actually (whereas one was kind the "base" for the other). So let me know if this makes sense for you, or if I should squash them. |
Thanks for the descriptions, this change makes sense as it is now. No need to squash. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhrazdil The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
(for the record)
Is this a BUG FIX or a FEATURE ?:
/kind enhancement
What this PR does / why we need it:
Currently the timestamps in the logs are in epoch format. This makes it really hard to get the time of the event. This PR uses the ISO8601 format for encoding timestamps:
instead of
In addition it adds the standard zap flags:
zap-devel
: Enable zap development mode (changes defaults to console encoder, debug log level, disables sampling and stacktrace from 'warning' level)")zap-encoder
: Zap log encoding (json
orconsole
)zap-level
: Zap log level (one ofdebug
,info
,error
or any integer value > 0)zap-stacktrace-level
: Set the minimum log level that triggers stacktrace generationThe
--v
parameter is marked as deprecated in favor ofzap-devel
.Special notes for your reviewer:
Unfortunately the standard zap flags don't provide a way to specify the timestamp format, so I had to set it "hard" to ISO8601.
Release note: