aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/error/elog.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2016-03-11 09:53:06 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2016-03-11 09:53:06 +0000
commit73e7e49da3b23a15cd84f003e11ad7d55ad80da7 (patch)
tree620324e097a9e3540bfd13a2af81fd5325075a1a /src/backend/utils/error/elog.c
parenta414d96ad2b001cddf10e3dedb0bde96d0af6a0b (diff)
downloadpostgresql-73e7e49da3b23a15cd84f003e11ad7d55ad80da7.tar.gz
postgresql-73e7e49da3b23a15cd84f003e11ad7d55ad80da7.zip
Allow emit_log_hook to see original message text
emit_log_hook could only see the translated text, making it harder to identify which message was being sent. Pass original text to allow the exact message to be identified, whichever language is used for logging. Discussion: 20160216.184755.59721141.horiguchi.kyotaro@lab.ntt.co.jp Author: Kyotaro Horiguchi
Diffstat (limited to 'src/backend/utils/error/elog.c')
-rw-r--r--src/backend/utils/error/elog.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 9005b261cda..5b7554b6ea1 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -801,6 +801,7 @@ errmsg(const char *fmt,...)
CHECK_STACK_DEPTH();
oldcontext = MemoryContextSwitchTo(edata->assoc_context);
+ edata->message_id = fmt;
EVALUATE_MESSAGE(edata->domain, message, false, true);
MemoryContextSwitchTo(oldcontext);
@@ -830,6 +831,7 @@ errmsg_internal(const char *fmt,...)
CHECK_STACK_DEPTH();
oldcontext = MemoryContextSwitchTo(edata->assoc_context);
+ edata->message_id = fmt;
EVALUATE_MESSAGE(edata->domain, message, false, false);
MemoryContextSwitchTo(oldcontext);
@@ -853,6 +855,7 @@ errmsg_plural(const char *fmt_singular, const char *fmt_plural,
CHECK_STACK_DEPTH();
oldcontext = MemoryContextSwitchTo(edata->assoc_context);
+ edata->message_id = fmt_singular;
EVALUATE_MESSAGE_PLURAL(edata->domain, message, false);
MemoryContextSwitchTo(oldcontext);
@@ -1361,6 +1364,7 @@ elog_finish(int elevel, const char *fmt,...)
recursion_depth++;
oldcontext = MemoryContextSwitchTo(edata->assoc_context);
+ edata->message_id = fmt;
EVALUATE_MESSAGE(edata->domain, message, false, false);
MemoryContextSwitchTo(oldcontext);
@@ -1420,6 +1424,7 @@ format_elog_string(const char *fmt,...)
oldcontext = MemoryContextSwitchTo(ErrorContext);
+ edata->message_id = fmt;
EVALUATE_MESSAGE(edata->domain, message, false, true);
MemoryContextSwitchTo(oldcontext);
@@ -1458,6 +1463,11 @@ EmitErrorReport(void)
* where it would have much less information available. emit_log_hook is
* intended for custom log filtering and custom log message transmission
* mechanisms.
+ *
+ * The log hook has access to both the translated and original English
+ * error message text, which is passed through to allow it to be used
+ * as a message identifier. Note that the original text is not available
+ * for detail, detail_log, hint and context text elements.
*/
if (edata->output_to_server && emit_log_hook)
(*emit_log_hook) (edata);