-
Notifications
You must be signed in to change notification settings - Fork 7
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: add —log-timestamps option #1025
Conversation
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.
Nice.
internal/log/configure.go
Outdated
JSON bool `help:"Log in JSON format." env:"LOG_JSON"` | ||
Level Level `help:"Log level." default:"info" env:"LOG_LEVEL"` | ||
JSON bool `help:"Log in JSON format." env:"LOG_JSON"` | ||
Timestamps bool `help:"Include relative timestamps in logs." env:"LOG_TIMESTAMPS"` |
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.
It might be good to clarify that this is only in plain text logs, not JSON logs.
cc @lamchau |
awesome, thanks for this! |
internal/log/plain.go
Outdated
case d < time.Minute: | ||
timestamp = fmt.Sprintf("%ds", d/time.Second) | ||
case d < time.Hour: | ||
timestamp = fmt.Sprintf("%dm", d/time.Minute) |
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.
Mmmm so I think this minute/hour granularity will not be super useful in practice. The rationale is that you will still want to be able to tell the relative difference between two log entries...
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 don't really have a great idea on how to format that though, to be honest.
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.
999ms
20s
10m 30s
1h 10m 30s
This could be more useful?
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 it would be okay to drop the spaces.
Though I wonder if at this point it shouldn't just be:
0.999
20
1:10:30
WDYT?
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.
1h10m30s
feels cramped to me in a way that 1:10:30
doesn't
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 do tend to agree 👍
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.
Maybe even 0:20
for seconds. A number by itself is a bit contextless
0.999
0:20
1:10:30
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.
At this point maybe we should just use the 24h time rather than relative?
16:07:23 info: foo
16:09:01 debug: bar
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.
Thinking it through... I think relative only makes sense if we mostly cared about startup times, but engineers using ftl would have ftl dev
running in the background through their day right? And when they look back at the logs the relative timestamps will be in the hours and not be easily convertible to "oh that was 30 mins ago", where as with non relative times it'll be pretty intuitive
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.
Updated the code to 24h timestamps
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
#1009
Adding
add --log-timestamps
include timestamps in terminal logsExample