What would be the easiest way to alter the format of the logging class output? Specifically, instead of writing the number of milliseconds as the timestamp, I would prefer the actual timestamp. Is there a reason not to do this that I am not thinking about? I’ve looked through the logging section of the DeviceOS but didn’t see where the millis() call is…? Should I just overwrite the logMessage
method?
You wouldn’t do this because the device isn’t guaranteed to have UTC at startup, and that will rely on the RTC driver anyway which probably isn’t happening immediately on boot. This means that the first few (or dozen or more) messages will have an invalid or nonexistent timestamp.
Additionally, if the local RTC is different from UTC, the timestamps can be non-monotonic when the time correction message comes in.
If you want to be able to process your logs by UTC, an easier way to accomplish this might be to log a special timestamp message after you ensure a valid local time and post-process the logs with a script that back-processes all the millisecond fields into UTC or UNIX time.
2 Likes
Makes sense - Thanks!
1 Like