-
Notifications
You must be signed in to change notification settings - Fork 632
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
Configurable log and timestamp formats (logfmt, ISO8601) #1022
Conversation
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1022 +/- ##
============================================
+ Coverage 70.61% 70.62% +0.01%
============================================
Files 114 114
Lines 61734 63125 +1391
============================================
+ Hits 43595 44584 +989
- Misses 18139 18541 +402
|
😀 thanks for opening this, we're working on launching the next version but will take a look shortly. |
I like this change. Free-form log lines can be tricky to parse and search, and this feels like a good step toward adopting more structured logging. We could even extend it further to include properties like "area" (e.g., "cluster," "normal replication," "dual channel replication," etc.). Thanks for your work on this, @azuredream! |
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
@valkey-io/core-team Please indicate your vote on this comment. The open questions I still have are if we want to also do the larger investigation before 8.1 launches about also including the component the log was generated from. We also have the JSON format to add on. |
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've reviewed this before in the open source redis time. I like it, just a few comments.
It seems that JSON is more popular. We can add that too in another PR.
Configurable time format is good.
src/server.c
Outdated
snprintf(buf + off, sizeof(buf) - off, "%03d%s", (int)tv.tv_usec / 1000, tzbuf); | ||
break; | ||
|
||
case LOG_TIMESTAMP_UNIX: snprintf(buf, sizeof(buf), "%ld", tv.tv_sec); break; |
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 think this should be in milliseconds, not seconds.
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
@madolson @zuiderkwast |
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
Demo logs: log-format logfmt
log-format legacy
log-format logfmt
log-format legacy
log-format logfmt
log-format legacy
|
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
Code updateded. |
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.
Looks good to me now.
One of the commits is missing sign-off. See the Details link on the DCO CI job. Can you fix it? You can squash and force-push as you want.
See also the clang-format CI job. It's a trailing whitespace on one line.
Is the Valkey logo logged on startup? It must look very weird with logfmt?
Actually it looks fine
|
Signed-off-by: azuredream <zhaozixuan67@gmail.com>
a6b0246
to
3b0084d
Compare
Updated comment, fixed format, fixed unsigned commit. I appreciate your continuous effort to review my contributions and provide valuable suggestions for improvements. |
Thanks, that's our job. :) Thanks for your patience! It's a bit weird that we print |
Please refer to the discussion around Jan 11th. We introduced reader friendly role string Intentionally.
|
I know we want reader-friendly role. What I think is weird is that we print RDB/AOF during startup. This is not a forked child process performing RDB dump or AOF rewrite. Now I see why: |
I think that means I don't need to update this PR. |
That's right, I hope this PR is ready to merge now. @madolson do you have any more comments before we merge this? @azuredream If you want to make a follow-up PR for the role during startup, please continue reading...
|
Sure. Please feel free to create an issue and assign to me. |
We don't need issues for everything, but if you insist... |
Document log format configs in valkey.conf Configs are documented there. We missed that. Let's do it as a follow-up. |
Add ability to configure log output format and timestamp format in the logs.
This change adds two new configs:
log-format
: Either legacy or logfmt (See https://brandur.org/logfmt)log-timestamp-format
: legacy, iso8601 or milliseconds (since the epoch).Related to #1006.
Example: