-
Notifications
You must be signed in to change notification settings - Fork 719
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
pkg/logutil: add json log format #626
pkg/logutil: add json log format #626
Conversation
andelf
commented
Apr 24, 2017
- log.format: text, json, console
- log rotate options
- log entry timestamp options
@@ -20,8 +20,21 @@ tso-save-interval = "3s" | |||
[log] | |||
level = "info" | |||
|
|||
#[log.file] | |||
# log format, one of json, text, console | |||
#format = "text" |
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.
em, I think most of the time, users don't use console even they run PD in the console. TEXT and JSON may be enough.
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.
colorful output. can be remove from comment, leave the function in code.
// Log format. one of json, text, or console. | ||
Format string `toml:"format" json:"format"` | ||
// Disable automatic timestamps in output. | ||
DisableTimestamp bool `toml:"disable-timestamp" json:"disable-timestamp"` |
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.
any benefit to disabling timestamp?
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.
ELK system will add a timestamp and it has more accuracy.
Enduser can also translate this timestamp in time
field via logstash.
pkg/logutil/log.go
Outdated
LocalTime: true, | ||
} | ||
|
||
if _, err := output.Write([]byte{}); err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to write to log, %v\n", err) |
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.
seem return error is enough.
Could we put this util to a standalone repo that all our Go projects can use it. |
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.
@tennix I guess it's ok to copy and paste util.go to other projects, it's very simple and other repos may want different default values or config layouts. |
LGTM |
coverage decreased, please add test. |
@siddontang |