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/