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

Commit2a217c3

Browse files
committed
Coordinate emit_log_hook and all log destinations to share the same timeval
This would cause the timestamp values used by emit_log_hook and all theother log destinations to differ, because the timestamps are resetbefore sending the logs to the server and after calling the hook.This change matters for emit_log_hook when generating log informationwith 'n' or 'm' in log_line_prefix through log_status_format(), or whendoing direct calls to get_formatted_log_time() like in the JSON or CSVlog formats.While on it, this commit fixes a couple of comments related to theformatted timestamps where the JSON was not mentioned. Oversight indc68668, that I have noticed while reviewing this patch.Author: Kambam Vinay, Michael PaquierDiscussion:https://postgr.es/m/CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com
1 parent44086b0 commit2a217c3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static intrecursion_depth = 0;/* to detect actual recursion */
154154

155155
/*
156156
* Saved timeval and buffers for formatted timestamps that might be used by
157-
*bothlog_line_prefixandcsv logs.
157+
* log_line_prefix, csv logsandJSON logs.
158158
*/
159159
staticstructtimevalsaved_timeval;
160160
staticboolsaved_timeval_set= false;
@@ -1678,6 +1678,14 @@ EmitErrorReport(void)
16781678
CHECK_STACK_DEPTH();
16791679
oldcontext=MemoryContextSwitchTo(edata->assoc_context);
16801680

1681+
/*
1682+
* Reset the formatted timestamp fields before emitting any logs. This
1683+
* includes all the log destinations and emit_log_hook, as the latter
1684+
* could use log_line_prefix or the formatted timestamps.
1685+
*/
1686+
saved_timeval_set= false;
1687+
formatted_log_time[0]='\0';
1688+
16811689
/*
16821690
* Call hook before sending message to log. The hook function is allowed
16831691
* to turn off edata->output_to_server, so we must recheck that afterward.
@@ -2632,7 +2640,7 @@ get_formatted_log_time(void)
26322640
/*
26332641
* Note: we expect that guc.c will ensure that log_timezone is set up (at
26342642
* least with a minimal GMT value) before Log_line_prefix can become
2635-
* nonempty or CSV mode can be selected.
2643+
* nonempty or CSV/JSON mode can be selected.
26362644
*/
26372645
pg_strftime(formatted_log_time,FORMATTED_TS_LEN,
26382646
/* leave room for milliseconds... */
@@ -2673,7 +2681,7 @@ get_formatted_start_time(void)
26732681
/*
26742682
* Note: we expect that guc.c will ensure that log_timezone is set up (at
26752683
* least with a minimal GMT value) before Log_line_prefix can become
2676-
* nonempty or CSV mode can be selected.
2684+
* nonempty or CSV/JSON mode can be selected.
26772685
*/
26782686
pg_strftime(formatted_start_time,FORMATTED_TS_LEN,
26792687
"%Y-%m-%d %H:%M:%S %Z",
@@ -3151,9 +3159,6 @@ send_message_to_server_log(ErrorData *edata)
31513159

31523160
initStringInfo(&buf);
31533161

3154-
saved_timeval_set= false;
3155-
formatted_log_time[0]='\0';
3156-
31573162
log_line_prefix(&buf,edata);
31583163
appendStringInfo(&buf,"%s: ",_(error_severity(edata->elevel)));
31593164

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp