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

Commitb40baa9

Browse files
committed
Provide log_status_format(), useful for an emit_log_hook.
Refactor so that log_line_prefix() is a thin wrapper over a newfunction log_status_format(), and move the implementation to thelatter. Export log_status_format() so that it can be used by anemit_log_hook.Discussion:https://postgr.es/m/39c8197652f4d3050aedafae79fa5af31096505f.camel%40j-davis.comReviewed-by: Michael Paquier, Alvaro Herrera
1 parentbf022d3 commitb40baa9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,10 +2438,19 @@ process_log_prefix_padding(const char *p, int *ppadding)
24382438
}
24392439

24402440
/*
2441-
* Formattag info forloglines; append to the provided buffer.
2441+
* Format logstatus information using Log_line_prefix.
24422442
*/
24432443
staticvoid
24442444
log_line_prefix(StringInfobuf,ErrorData*edata)
2445+
{
2446+
log_status_format(buf,Log_line_prefix,edata);
2447+
}
2448+
2449+
/*
2450+
* Format log status info; append to the provided buffer.
2451+
*/
2452+
void
2453+
log_status_format(StringInfobuf,constchar*format,ErrorData*edata)
24452454
{
24462455
/* static counter for line numbers */
24472456
staticlonglog_line_number=0;
@@ -2465,10 +2474,10 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
24652474
}
24662475
log_line_number++;
24672476

2468-
if (Log_line_prefix==NULL)
2477+
if (format==NULL)
24692478
return;/* in case guc hasn't run yet */
24702479

2471-
for (p=Log_line_prefix;*p!='\0';p++)
2480+
for (p=format;*p!='\0';p++)
24722481
{
24732482
if (*p!='%')
24742483
{

‎src/include/utils/elog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include<setjmp.h>
1818

19+
#include"lib/stringinfo.h"
20+
1921
/* Error level codes */
2022
#defineDEBUG510/* Debugging messages, in categories of
2123
* decreasing detail. */
@@ -439,6 +441,8 @@ extern PGDLLIMPORT bool syslog_split_messages;
439441
#defineLOG_DESTINATION_JSONLOG16
440442

441443
/* Other exported functions */
444+
externvoidlog_status_format(StringInfobuf,constchar*format,
445+
ErrorData*edata);
442446
externvoidDebugFileOpen(void);
443447
externchar*unpack_sql_state(intsql_state);
444448
externboolin_error_recursion_trouble(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp