From bd0b1b229dca2bec991cc4c57363fe93abf5db34 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 11 Jul 2005 23:13:39 +0000 Subject: [PATCH] STABLE14-auditlog-include-timestamp-20050710 add a timestamp to auditlog (cherry picked from commit 855d3669b28707afd8f9fe59d2a857eafb0552af) --- src/audit/audit.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/audit/audit.c b/src/audit/audit.c index 99533f43e..93c4ba6ef 100644 --- a/src/audit/audit.c +++ b/src/audit/audit.c @@ -148,10 +148,21 @@ printbuf(FILE *out, int rec, char *audEvent, afs_int32 errCode, va_list vaList) struct AFSCBFids *vaFids; int num = LogThreadNum(); struct in_addr hostAddr; - - /* Don't print the thread id if we recursed */ - if ((num > -1) && (rec == 0)) - fprintf(out, "[%d]:", num); + time_t currenttime; + char *timeStamp; + char tbuffer[26]; + + /* Don't print the timestamp or thread id if we recursed */ + if (rec == 0) { + currenttime = time(0); + timeStamp = afs_ctime(¤ttime, tbuffer, + sizeof(tbuffer)); + timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */ + fprintf(out, timeStamp); + + if (num > -1) + fprintf(out, "[%d] ", num); + } if (strcmp(audEvent, "VALST") != 0) fprintf(out, "EVENT %s CODE %d ", audEvent, errCode); -- 2.39.5