Is there a way to change the timestamp format in the logs? Something a bit more readable than time from epoch in hex would be nice.
Nick
Nick Folino wrote:
Is there a way to change the timestamp format in the logs?
The log timestamps are printed in hex because it has the cheapest formatting cost.
Something a bit more readable than time from epoch in hex would be nice.
Use your favorite text processing language to postprocess the logs. perl or awk would be easy.
This awk script will do the job:
#### /^[0-9a-f]+.[0-9a-f]/{ split($1, stamp, ".") ts = "0x" stamp[1] "" us = "0x" stamp[2] "" tsn = strtonum( ts ) usn = strtonum( us ) ns = strftime( "%Y%m%d %T", tsn ) "." usn $1 = ns } { print } ####
awk -f stamp.awk < slapd.log | less
Howard Chu wrote:
Nick Folino wrote:
Is there a way to change the timestamp format in the logs?
The log timestamps are printed in hex because it has the cheapest formatting cost.
Something a bit more readable than time from epoch in hex would be nice.
Use your favorite text processing language to postprocess the logs. perl or awk would be easy.
This awk script will do the job:
Slight fix to fractional seconds field width #### /^[0-9a-f]+.[0-9a-f]/{ split($1, stamp, ".") ts = "0x" stamp[1] "" us = "0x" stamp[2] "" tsn = strtonum( ts ) usn = strtonum( us ) sus = sprintf( "%0" (length( stamp[2] ) + 1) "d", usn ) $1 = strftime( "%Y-%m-%d %T", tsn ) "." sus } { print } ####
awk -f stamp.awk < slapd.log | less
Thanks, Howard. That's basically what I'm doing now. Just checking to see if there was an option I was missing.
Nick
On Fri, Oct 15, 2021 at 4:05 PM Howard Chu hyc@symas.com wrote:
Howard Chu wrote:
Nick Folino wrote:
Is there a way to change the timestamp format in the logs?
The log timestamps are printed in hex because it has the cheapest
formatting cost.
Something a bit more readable than time from epoch in hex would be nice.
Use your favorite text processing language to postprocess the logs. perl
or awk
would be easy.
This awk script will do the job:
Slight fix to fractional seconds field width #### /^[0-9a-f]+.[0-9a-f]/{ split($1, stamp, ".") ts = "0x" stamp[1] "" us = "0x" stamp[2] "" tsn = strtonum( ts ) usn = strtonum( us ) sus = sprintf( "%0" (length( stamp[2] ) + 1) "d", usn ) $1 = strftime( "%Y-%m-%d %T", tsn ) "." sus } { print } ####
awk -f stamp.awk < slapd.log | less
-- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/
Am 16.10.21 um 00:06 schrieb Nick Folino:
Thanks, Howard. That's basically what I'm doing now. Just checking to see if there was an option I was missing.
Hello,
just an idea: maybe a similar function could be added to slapd itself. One clean & reasonable fast implementation take the burden of inventing that wheel again and again from many users. A new config options would allow to enable convenient timestamp logging.
Andreas
A. Schulze wrote:
Am 16.10.21 um 00:06 schrieb Nick Folino:
Thanks, Howard. That's basically what I'm doing now. Just checking to see if there was an option I was missing.
Hello,
just an idea: maybe a similar function could be added to slapd itself. One clean & reasonable fast implementation take the burden of inventing that wheel again and again from many users. A new config options would allow to enable convenient timestamp logging.
No. The point of the new logging work is to get maximum performance, because logging is such a bottleneck. We will not add anything else to this code path in slapd. It's trivially easy to post-process this elsewhere when performance doesn't matter.
On Sat, Oct 16, 2021 at 04:11:25PM +0200, A. Schulze wrote:
Am 16.10.21 um 00:06 schrieb Nick Folino:
Thanks, Howard. That's basically what I'm doing now. Just checking to see if there was an option I was missing.
Hello,
just an idea: maybe a similar function could be added to slapd itself. One clean & reasonable fast implementation take the burden of inventing that wheel again and again from many users. A new config options would allow to enable convenient timestamp logging.
Hi, OpenLDAP is still capable of logging to syslog and that formats timestamps in a way that suits causal needs (and is generally configurable). The dedicated logfile option is there for sites where syslog is not appropriate as it has proven to be a significant performance bottleneck even with logging set to "stats" only.
openldap-technical@openldap.org