Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
Re: ts(1) & ISO8601 by default (Was: httpd: add timestamps to fastcgi error log)
To:
Job Snijders <job@bsd.nl>, tech@openbsd.org
Date:
Mon, 02 Nov 2026 19:24:43 +0000

Download raw body.

Thread
  • Klemens Nanni:

    ts(1) & ISO8601 by default (Was: httpd: add timestamps to fastcgi error log)

  • 02.11.2026 16:16, Job Snijders пишет:
    > Somewhat related: tools like ts(1) use strftime(3) for the format,
    > but strftime(3) does not provide an easy single character conversion
    > specification for ISO8601 timestamps. You have to do something like
    > 'echo hi | ts %Y-%m-%dT%H:%M:%SZ', which is a bit long.
    > 
    > Does anyone see some way to improve on this? Some options I considered:
    > 
    > Adding an extra option to ts(1) seems less desirable because it would
    > somewhat conflict with the interface people are used to.
    > 
    > Maybe just changing the default format in ts to '%Y-%m-%dT%H:%M:%SZ'
    > might be better?
    > 
    > Or perhaps strftime(3) could be extended?
    
    The more annoying part to me is that strptime(3) is unable to consume
    milliseconds produced by syslogd(8) -Z and ts(1) (TIL it offers that).
    
    So parsing zulu-timestamped syslogs in C gets ugly;  one hack I did
    is looking for the ISO8061 part without %z and, if a dot plus three
    digits follow, overwrite them with spaces to consume the scribbled
    string via "...%s%t%z".
    
    Hopefully this week I find some time and way to make our timestamps
    round-trip safe without ugly hacks.
    
    
  • Klemens Nanni:

    ts(1) & ISO8601 by default (Was: httpd: add timestamps to fastcgi error log)