Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broker: add year to log timestamps #6574

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading