-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Add timestamps to stdout, file loggers and editor Output panel #77263
base: master
Are you sure you want to change the base?
Conversation
1a14a8d
to
c375a2c
Compare
c375a2c
to
07f10e9
Compare
I've fixed timestamps not appearing in the written log files, so this PR is now ready for review. Thanks @SlugFiller for the help 🙂 |
07f10e9
to
71ac0e8
Compare
71ac0e8
to
24f14c2
Compare
Doesn't compile. How expensive are the added timestamp and timezone calculations on each message? Logging/printing is already fairly expensive, we should be careful about possibly increasingly its cost significantly. |
24f14c2
to
6cbfe49
Compare
I've fixed compilation and have benchmarked the new logging code. Unfortunately, it's about 4× slower than before in a debug build, with each log taking on average 8 microseconds (where it previously required 1-2 microseconds). This isn't due to using the higher-level String approach (I've tried replacing the timestamp string with a constant), but |
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.
Blocking merge for now as the performance hit is too heavy.
6cbfe49
to
5e15d79
Compare
Timestamps use ISO 8601 format, prefixing every printed line with `YYYY-MM-DDTHH:MM:SS+HH:MM |`. In the editor, they use `YYYY-MM-DD HH:MM:SS` for better readability. Both are printed in local time. Timestamp display can be toggled separately for stdout/stderr and file loggers in the Project Settings. By default, timestamps are logged to files, are not printed in stdout/stderr and are not shown in the editor Output panel.
5e15d79
to
769a6cb
Compare
As a way to minimize performance impact, would it be useful to only log ticks (formatted in MM:SS:msec) rather than system time? The log file itself I believe has the process launch time in the filename, so it would be possible to figure out the absolute time if needed. |
Yeah I think using engine tick count would definitely be the way to go. It can still be formatted as absolute time if wanted, by calculating the diff to the original system time when the tick count started. It might drift a bit but for this purpose it's probably not critical. Alternatively, a relative time since the start of the process also makes sense to me in a game log context (i.e. "how far into the game session did the user run into these bugs?"). We still need to make sure that whatever calculations are done for pretty formatting aren't too heavy - but avoiding system calls is definitely a must if we want to log timestamps. |
Timestamps use ISO 8601 format, prefixing every printed line with
YYYY-MM-DDTHH:MM:SS+HH:MM |
.+HH:MM
at the end denotes the timezone offset. In the editor, they useYYYY-MM-DD HH:MM:SS
for better readability. Both are printed in local time.Timestamp display can be toggled separately for stdout/stderr and file loggers in the Project Settings. By default, timestamps are logged to files, are not printed in stdout/stderr and are not shown in the editor Output panel. The "compact identical lines" option in the editor Output panel works correctly when timestamps are shown, with the timestamp becoming the time of the latest print.
TODO
master
takes 1.8s to log and print 200,000 lines (with stdout not being displayed in terminal), and this PR takes 3.1s.1master
and this PR takes 2.2s.1Example log file
Footnotes
These metrics include engine startup and shutdown, as this was measured using
hyperfine
and the--quit
CLI argument. ↩ ↩2