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

Commit570bd2b

Browse files
committed
Add capability to suppress CONTEXT: messages to elog machinery.
Hiding context messages usually is not a good idea - except for ratherverbose debugging/development utensils like LOG_DEBUG. There theamount of repeated context messages just bloat the log without addinginformation.
1 parent4a55931 commit570bd2b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,25 @@ errhidestmt(bool hide_stmt)
10811081
return0;/* return value does not matter */
10821082
}
10831083

1084+
/*
1085+
* errhidestmt --- optionally suppress CONTEXT: field of log entry
1086+
*
1087+
* This should only be used for verbose debugging messages where the repeated
1088+
* inclusion of CONTEXT: bloats the log volume too much.
1089+
*/
1090+
int
1091+
errhidecontext(boolhide_ctx)
1092+
{
1093+
ErrorData*edata=&errordata[errordata_stack_depth];
1094+
1095+
/* we don't bother incrementing recursion_depth */
1096+
CHECK_STACK_DEPTH();
1097+
1098+
edata->hide_ctx=hide_ctx;
1099+
1100+
return0;/* return value does not matter */
1101+
}
1102+
10841103

10851104
/*
10861105
* errfunction --- add reporting function name to the current error
@@ -2724,7 +2743,8 @@ write_csvlog(ErrorData *edata)
27242743
appendStringInfoChar(&buf,',');
27252744

27262745
/* errcontext */
2727-
appendCSVLiteral(&buf,edata->context);
2746+
if (!edata->hide_ctx)
2747+
appendCSVLiteral(&buf,edata->context);
27282748
appendStringInfoChar(&buf,',');
27292749

27302750
/* user query --- only reported if not disabled by the caller */
@@ -2856,7 +2876,7 @@ send_message_to_server_log(ErrorData *edata)
28562876
append_with_tabs(&buf,edata->internalquery);
28572877
appendStringInfoChar(&buf,'\n');
28582878
}
2859-
if (edata->context)
2879+
if (edata->context&& !edata->hide_ctx)
28602880
{
28612881
log_line_prefix(&buf,edata);
28622882
appendStringInfoString(&buf,_("CONTEXT: "));

‎src/include/utils/elog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ errcontext_msg(const char *fmt,...)
221221
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
222222

223223
externinterrhidestmt(boolhide_stmt);
224+
externinterrhidecontext(boolhide_ctx);
224225

225226
externinterrfunction(constchar*funcname);
226227
externinterrposition(intcursorpos);
@@ -385,6 +386,7 @@ typedef struct ErrorData
385386
booloutput_to_client;/* will report to client? */
386387
boolshow_funcname;/* true to force funcname inclusion */
387388
boolhide_stmt;/* true to prevent STATEMENT: inclusion */
389+
boolhide_ctx;/* true to prevent CONTEXT: inclusion */
388390
constchar*filename;/* __FILE__ of ereport() call */
389391
intlineno;/* __LINE__ of ereport() call */
390392
constchar*funcname;/* __func__ of ereport() call */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp