1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

Add log_line_prefix option 'n' for Unix epoch.

Prints time as Unix epoch with milliseconds.

Tomas Vondra, reviewed by Fabien Coelho.
This commit is contained in:
Jeff Davis
2015-09-07 13:46:31 -07:00
parent 37239ef8c9
commit f828654e10
3 changed files with 20 additions and 0 deletions

View File

@@ -2438,6 +2438,20 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
appendStringInfoString(buf, strfbuf);
}
break;
case 'n':
{
struct timeval tv;
char strfbuf[128];
gettimeofday(&tv, NULL);
sprintf(strfbuf, "%ld.%03d", tv.tv_sec, (int)(tv.tv_usec / 1000));
if (padding != 0)
appendStringInfo(buf, "%*s", padding, strfbuf);
else
appendStringInfoString(buf, strfbuf);
}
break;
case 's':
if (formatted_start_time[0] == '\0')
setup_formatted_start_time();