aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/error
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2014-12-25 17:24:30 +0100
committerAndres Freund <andres@anarazel.de>2014-12-25 17:24:30 +0100
commit570bd2b3fd20d3f8896f5e6a8133d6aed385ac86 (patch)
treeefe1dc192a7b1f28b9c397589c3ed2de7d5cf737 /src/backend/utils/error
parent4a5593197b0ddec913fcd7758d61e782ab5c4d59 (diff)
downloadpostgresql-570bd2b3fd20d3f8896f5e6a8133d6aed385ac86.tar.gz
postgresql-570bd2b3fd20d3f8896f5e6a8133d6aed385ac86.zip
Add capability to suppress CONTEXT: messages to elog machinery.
Hiding context messages usually is not a good idea - except for rather verbose debugging/development utensils like LOG_DEBUG. There the amount of repeated context messages just bloat the log without adding information.
Diffstat (limited to 'src/backend/utils/error')
-rw-r--r--src/backend/utils/error/elog.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 23164648191..8f04b19744d 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1081,6 +1081,25 @@ errhidestmt(bool hide_stmt)
return 0; /* return value does not matter */
}
+/*
+ * errhidestmt --- optionally suppress CONTEXT: field of log entry
+ *
+ * This should only be used for verbose debugging messages where the repeated
+ * inclusion of CONTEXT: bloats the log volume too much.
+ */
+int
+errhidecontext(bool hide_ctx)
+{
+ ErrorData *edata = &errordata[errordata_stack_depth];
+
+ /* we don't bother incrementing recursion_depth */
+ CHECK_STACK_DEPTH();
+
+ edata->hide_ctx = hide_ctx;
+
+ return 0; /* return value does not matter */
+}
+
/*
* errfunction --- add reporting function name to the current error
@@ -2724,7 +2743,8 @@ write_csvlog(ErrorData *edata)
appendStringInfoChar(&buf, ',');
/* errcontext */
- appendCSVLiteral(&buf, edata->context);
+ if (!edata->hide_ctx)
+ appendCSVLiteral(&buf, edata->context);
appendStringInfoChar(&buf, ',');
/* user query --- only reported if not disabled by the caller */
@@ -2856,7 +2876,7 @@ send_message_to_server_log(ErrorData *edata)
append_with_tabs(&buf, edata->internalquery);
appendStringInfoChar(&buf, '\n');
}
- if (edata->context)
+ if (edata->context && !edata->hide_ctx)
{
log_line_prefix(&buf, edata);
appendStringInfoString(&buf, _("CONTEXT: "));