Mark D. Baushke
2015-Oct-29 01:32 UTC
[Bug 2464] Adding timestamp to debug messages (log.c:do_log)
Diff updated with suggested changes (also, making the timestamp format ISO8601 compliant). Hmmm... full IOS8601 compliance would include the timzeone so the format string would be "%Y%m%dT%H%M%S%z" (and need to increase the size of the timebuf[20] by one byte or you would use gmtime() instead of localtime() and the format string "%Y%m%dT%H%M%SZ". I think gmtime() may be simpler. -- Mark
Mark D. Baushke
2015-Oct-29 02:11 UTC
[Bug 2464] Adding timestamp to debug messages (log.c:do_log)
Stephen Harris <lists at spuddy.org> writes:> On Wed, Oct 28, 2015 at 06:32:16PM -0700, Mark D. Baushke wrote: > > and the format string "%Y%m%dT%H%M%SZ". I think gmtime() may be simpler. > > The world should live in GMT. Unfortunately people want their logs > to be consitent on a machine; syslog reports in localtime so we should > report in localtime :-(I understand. I observed that the current patch was not a complete IS8601 timestamp as it was missing the timezeone. If localtime() is used, then %z should be added to the format which takes 21 charcters yyyymmddThhmmss-zzzz\0 or yyyymmddThhmmss+zzzz\0 that is 20 printable characters and the NUL byte to terminate the string. -- Mark
Mark D. Baushke
2015-Oct-29 02:23 UTC
[Bug 2464] Adding timestamp to debug messages (log.c:do_log)
Darren Tucker <dtucker at zip.com.au> writes:> On Thu, Oct 29, 2015 at 12:32 PM, Mark D. Baushke <mdb at juniper.net> wrote: > > Diff updated with suggested changes (also, making the timestamp format > > ISO8601 compliant). > > > > Hmmm... full IOS8601 compliance would include the timzeone so the format > > I don't have a copy of the ISO8601 text, but the wikipedia page says > "If no UTC relation information is given with a time representation, > the time is assumed to be in local time." Which in this case it is.Hmmm... I could be wrong here as I have not read the actual ISO 8601 standard since 1999, but the form 'YYYY-MM-DD HH:MM:SS' is the form where the lack of a timezone indicated local time. I do recall that a default local time was generally discouraged as being ambiguous. In any case, I am more interested in syslog() being used rather than an ISO 8601 format time and wonder what use case needs to use strftime() foromats at all. -- Mark
Seemingly Similar Threads
- [Bug 2464] Adding timestamp to debug messages (log.c:do_log)
- [Bug 2464] New: Adding timestamp to debug messages (log.c:do_log)
- [Bug 2464] New: Adding timestamp to debug messages (log.c:do_log)
- strptime with +03:00 zone designator
- strptime with +03:00 zone designator