Anand Buddhdev
2014-Feb-13 08:25 UTC
[nsd-users] Feature request: human-readable timestamps in logs
Hi NSD developers, NSD currently writes logs with unix timestamps, like this: [1392279213] nsd[13845]: info: notify for lv. from 193.0.0.198 When reading these logs, I have to keep converting the unix timestamp to human-readable. Could you please get NSD to optionally log directly in human-readable timestamps of the form: 2014-02-13T03:37:02 .... Regards, Anand
Bas van den Dikkenberg
2014-Feb-13 08:30 UTC
[nsd-users] Feature request: human-readable timestamps in logs
+1> -----Oorspronkelijk bericht----- > Van: nsd-users [mailto:nsd-users-bounces at NLnetLabs.nl] Namens Anand > Buddhdev > Verzonden: donderdag 13 februari 2014 09:26 > Aan: nsd-users at NLnetLabs.nl > Onderwerp: [nsd-users] Feature request: human-readable timestamps in > logs > > Hi NSD developers, > > NSD currently writes logs with unix timestamps, like this: > > [1392279213] nsd[13845]: info: notify for lv. from 193.0.0.198 > > When reading these logs, I have to keep converting the unix timestamp to > human-readable. Could you please get NSD to optionally log directly in > human-readable timestamps of the form: > > 2014-02-13T03:37:02 .... > > Regards, > Anand > _______________________________________________ > nsd-users mailing list > nsd-users at NLnetLabs.nl > http://open.nlnetlabs.nl/mailman/listinfo/nsd-users
Stephane Bortzmeyer
2014-Feb-13 08:46 UTC
[nsd-users] Feature request: human-readable timestamps in logs
On Thu, Feb 13, 2014 at 09:25:41AM +0100, Anand Buddhdev <anandb at ripe.net> wrote a message of 18 lines which said:> NSD currently writes logs with unix timestamps, like this: > > [1392279213] nsd[13845]: info: notify for lv. from 193.0.0.198 > > When reading these logs, I have to keep converting the unix timestamp to > human-readable. Could you please get NSD to optionally log directly in > human-readable timestamps of the form:Often requested for software which does the same (Squid, Nagios). The solution I use is in the Squid FAQ. Here, for Icinga : #!/bin/sh tail -f /var/log/icinga/icinga.log | perl -p -e 's/^\[(.*)\]/"[". localtime($1) . "]"/e'
Lukas Wunner
2014-Feb-13 12:35 UTC
[nsd-users] Feature request: human-readable timestamps in logs
Hi,> When reading these logs, I have to keep converting the unix timestamp to > human-readable. Could you please get NSD to optionally log directly in > human-readable timestamps of the form:Attached is a small patch we use in our tailor-made NSD RPM to achieve that. (It's not an option though.) Kind regards, Lukas -------------- next part -------------- --- util.c.orig 2013-01-09 12:58:15.000000000 +0000 +++ util.c 2013-03-20 23:30:03.000000000 +0000 @@ -125,6 +125,8 @@ size_t length; lookup_table_type *priority_info; const char *priority_text = "unknown"; + time_t now; + char *cnow; assert(global_ident); assert(current_log_file); @@ -135,8 +137,10 @@ } /* Bug #104, add time_t timestamp */ - fprintf(current_log_file, "[%d] %s[%d]: %s: %s", - (int)time(NULL), global_ident, (int) getpid(), priority_text, message); + now = time(NULL); + cnow = ctime(&now); + fprintf(current_log_file, "[%.*s] %s[%d]: %s: %s", + strlen(cnow)-1, cnow, global_ident, (int) getpid(), priority_text, message); length = strlen(message); if (length == 0 || message[length - 1] != '\n') { fprintf(current_log_file, "\n");