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

Remove timestamps and pid from logged lines. #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 2 additions & 6 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ void
VWLOG(int level, const char *fmt, va_list ap)
{
struct timeval tv;
struct tm tm;
char buf[1024];
int n;
va_list ap1;

va_copy(ap1, ap);
Expand All @@ -113,6 +111,7 @@ VWLOG(int level, const char *fmt, va_list ap)
va_end(ap1);
return;
}

AZ(gettimeofday(&tv, NULL));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can avoid calling gettimeofday(...) too.

if (logfile != stdout && logfile != stderr
&& tv.tv_sec >= logf_check_t + LOG_REOPEN_INTERVAL) {
Expand All @@ -130,10 +129,7 @@ VWLOG(int level, const char *fmt, va_list ap)
logf_check_t = tv.tv_sec;
}

AN(localtime_r(&tv.tv_sec, &tm));
n = strftime(buf, sizeof(buf), "%Y%m%dT%H%M%S", &tm);
snprintf(buf + n, sizeof(buf) - n, ".%06d [%5d] %s",
(int) tv.tv_usec, getpid(), fmt);
snprintf(buf, sizeof(buf), "%s", fmt);
vfprintf(logfile, buf, ap1);
va_end(ap1);
}
Expand Down