Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf828654

Browse files
committed
Add log_line_prefix option 'n' for Unix epoch.
Prints time as Unix epoch with milliseconds.Tomas Vondra, reviewed by Fabien Coelho.
1 parent37239ef commitf828654

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,11 @@ local0.* /var/log/postgresql
46294629
<entry>Time stamp with milliseconds</entry>
46304630
<entry>no</entry>
46314631
</row>
4632+
<row>
4633+
<entry><literal>%n</literal></entry>
4634+
<entry>Time stamp with milliseconds (as a Unix epoch)</entry>
4635+
<entry>no</entry>
4636+
</row>
46324637
<row>
46334638
<entry><literal>%i</literal></entry>
46344639
<entry>Command tag: type of session's current command</entry>

‎src/backend/utils/error/elog.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,20 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
24382438
appendStringInfoString(buf,strfbuf);
24392439
}
24402440
break;
2441+
case'n':
2442+
{
2443+
structtimevaltv;
2444+
charstrfbuf[128];
2445+
2446+
gettimeofday(&tv,NULL);
2447+
sprintf(strfbuf,"%ld.%03d",tv.tv_sec, (int)(tv.tv_usec /1000));
2448+
2449+
if (padding!=0)
2450+
appendStringInfo(buf,"%*s",padding,strfbuf);
2451+
else
2452+
appendStringInfoString(buf,strfbuf);
2453+
}
2454+
break;
24412455
case's':
24422456
if (formatted_start_time[0]=='\0')
24432457
setup_formatted_start_time();

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@
425425
# %p = process ID
426426
# %t = timestamp without milliseconds
427427
# %m = timestamp with milliseconds
428+
# %n = timestamp with milliseconds (as a Unix epoch)
428429
# %i = command tag
429430
# %e = SQL state
430431
# %c = session ID

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp