Skip to content

Commit

Permalink
Merge pull request #6574 from grondo/issue#6569
Browse files Browse the repository at this point in the history
broker: add year to log timestamps
  • Loading branch information
mergify[bot] authored Jan 23, 2025
2 parents 2088011 + 014ace5 commit ef85a55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/broker/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,16 @@ static void log_timestamp (FILE *fp,
struct timeval tv;
char datetime[16]; /* 'MMM DD HH:MM:SS' */
char timezone[16]; /* TZ abbrev should be short, give 15 chars max */
char year[5]; /* 4 digit year */

if (flags & LOG_NO_TIMESTAMP)
return;
if (timestamp_parse (hdr->timestamp, &tm, &tv) < 0
|| strftime (datetime, sizeof (datetime), "%b %d %T", &tm) == 0
|| strftime (timezone, sizeof (timezone), "%Z", &tm) == 0)
|| strftime (timezone, sizeof (timezone), "%Z", &tm) == 0
|| strftime (year, sizeof (year), "%Y", &tm) == 0)
fprintf (fp, "%s ", hdr->timestamp);
fprintf (fp, "%s.%06ld %s ", datetime, (long)tv.tv_usec, timezone);
fprintf (fp, "%s.%06ld %s %s ", datetime, (long)tv.tv_usec, timezone, year);
}

/* Log a message to 'fp', if non-NULL.
Expand Down

0 comments on commit ef85a55

Please sign in to comment.