-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Logging improvements #14760
base: master
Are you sure you want to change the base?
Logging improvements #14760
Conversation
Can you paste an example log before and after? I don't remember, did we include the timezone in the timestamps? I think rather than adding an optional argument that almost no one will use (so it won't help with debugging in general, and it can even make it worse because now you won't know if someone's using local time or UTC) it'd probably be better to just have the timezone in the logs, and then you'd have the best of both worlds - people would see their local timezone by default as it is now, but you'd be able to easily transform the logs into UTC. Also, I don't think we want to box the timer and use chrono for the timestamps. IIRC I introduced the |
Before:
After:
That is the point, I don't care what their timezone is as long as logs are always in UTC. And I certainly don't want to write scripts that extract timezones from logs and convert them all back to UTC so logs from different places and apps are comparable. The plan was to make this flag default to Also in our case node is not just binary, but also a library, which when combined with other libraries makes logs look confusing with different timezones interleaved. We really want just UTC everywhere all the time.
Interesting, do you have a benchmark for this? It is hard to see how a single trait object would cause massive issues, but I guess everything is possible. |
If we're going to fix the issue of "it's hard to correlate logs together because of different timestamp timezones" I'd rather we go all the way and fix it for everyone, not just for your particular use case. And having a default implicit timezone, whether it's local time or UTC, is not helpful if everyone doesn't use the same timezone. I'd be fine with adding this flag to force UTC timezones on the condition that we just change the timestamp format to always include the timezone regardless of how the logger is configured. So then it'll be always unambiguous which timezone is used, while simultaneously letting you go UTC-only if you want.
It was a long time ago so I don't remember the details, but I vaguely remember that it made a difference. (Not necessarily due to boxing but mostly due to formatting overhead, I think? But again, I don't remember the details.) You should be able to modify |
I just need it to be the same format as default I think the high-level issue is that logging is not really configurable from the outside right now. Someone did an attempt in that direction with
I can do that, just want to make sure we are on the same page as to what the result should look here first. |
Ugly or not, practicality trumps aesthetics. Being able to correlate logs regardless of the timezone and their source is a pretty useful feature. (And myself I often too found it painful when debugging 3rd-party logs, so I'd be happy to get it fixed.) As long as the timezone is included I'm fine with whatever default
Sure. Let me just ping @paritytech/sdk-node in case anyone has any objections. If not we can just go ahead with always including the timezone in the timestamps and adding your flag to force it to emit timestamps in UTC. |
Fine by me, but can you give an example on how "timezone in the timestamps" looks like? |
I feel like what you're asking is to allow customization of the formatting for the date/time, which will be equivalent performance-wise to what this PR suggests for UTC, but apparently not as fast as purpose-built formatting would be. I'm fine with it, but I'm not running trace level logs very often, so maybe performance hit is prohibitive there, no idea. |
@bkchr This depends on the timestamp format (of which are
and after:
(where |
This is something that bothered me for a long time. Defaulting logs to local time is confusing when debugging issues happening on machines all around the world.
This PR primarily introduces
--use-utc-log-time
CLI argument that reverts time format to what tracing-subscriber uses by default. I didn't want to change the default, but arguably UTC should have been the default all along.While at it I also added support for
NO_COLOR
, though better approach might be to remove--disable-log-color
altogether and usesupports-color
that automatically takes this environment variable into account (see tokio-rs/tracing#2388 and tokio-rs/tracing#2214).Fixes #11734