summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane2007-03-02 23:37:23 +0000
committerTom Lane2007-03-02 23:37:23 +0000
commit61c3e5b2486825ee65da322e1408286a8c0d5de6 (patch)
treefa11fd0d50762edf630370c04bbcd5b79c8129be /src/backend/utils
parent1a7f6302bc044ac2e9027be1f94118e029c64ed9 (diff)
Make log_min_error_statement put LOG level at the same priority as
log_min_messages does; and arrange to suppress the duplicative output that would otherwise result from log_statement and log_duration messages. Bruce Momjian and Tom Lane.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/error/elog.c40
-rw-r--r--src/backend/utils/misc/postgresql.conf.sample11
2 files changed, 40 insertions, 11 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 3700c4ecdc0..c76d817bb14 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -42,7 +42,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.182 2007/02/11 11:59:26 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.183 2007/03/02 23:37:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -732,6 +732,25 @@ errcontext(const char *fmt,...)
/*
+ * errhidestmt --- optionally suppress STATEMENT: field of log entry
+ *
+ * This should be called if the message text already includes the statement.
+ */
+int
+errhidestmt(bool hide_stmt)
+{
+ ErrorData *edata = &errordata[errordata_stack_depth];
+
+ /* we don't bother incrementing recursion_depth */
+ CHECK_STACK_DEPTH();
+
+ edata->hide_stmt = hide_stmt;
+
+ return 0; /* return value does not matter */
+}
+
+
+/*
* errfunction --- add reporting function name to the current error
*
* This is used when backwards compatibility demands that the function
@@ -1629,7 +1648,9 @@ send_message_to_server_log(ErrorData *edata)
/*
* If the user wants the query that generated this error logged, do it.
*/
- if (edata->elevel >= log_min_error_statement && debug_query_string != NULL)
+ if (is_log_level_output(edata->elevel, log_min_error_statement) &&
+ debug_query_string != NULL &&
+ !edata->hide_stmt)
{
log_line_prefix(&buf);
appendStringInfoString(&buf, _("STATEMENT: "));
@@ -2046,7 +2067,7 @@ write_stderr(const char *fmt,...)
vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
- write_eventlog(EVENTLOG_ERROR_TYPE, errbuf);
+ write_eventlog(ERROR, errbuf);
}
else
/* Not running as service, write to stderr */
@@ -2055,13 +2076,18 @@ write_stderr(const char *fmt,...)
va_end(ap);
}
+
+/*
+ * is_log_level_output -- is elevel logically >= log_min_level?
+ *
+ * We use this for tests that should consider LOG to sort out-of-order,
+ * between ERROR and FATAL. Generally this is the right thing for testing
+ * whether a message should go to the postmaster log, whereas a simple >=
+ * test is correct for testing whether the message should go to the client.
+ */
static bool
is_log_level_output(int elevel, int log_min_level)
{
- /*
- * Complicated because LOG is sorted out-of-order here, between
- * ERROR and FATAL.
- */
if (elevel == LOG || elevel == COMMERROR)
{
if (log_min_level == LOG || log_min_level <= ERROR)
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 703f5cbaa33..77a86f0020b 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -262,7 +262,7 @@
# - When to Log -
-#client_min_messages = notice # Values, in order of decreasing detail:
+#client_min_messages = notice # Values in order of decreasing detail:
# debug5
# debug4
# debug3
@@ -273,7 +273,7 @@
# warning
# error
-#log_min_messages = notice # Values, in order of decreasing detail:
+#log_min_messages = notice # Values in order of decreasing detail:
# debug5
# debug4
# debug3
@@ -289,7 +289,7 @@
#log_error_verbosity = default # terse, default, or verbose messages
-#log_min_error_statement = error # Values in order of increasing severity:
+#log_min_error_statement = error # Values in order of decreasing detail:
# debug5
# debug4
# debug3
@@ -299,11 +299,14 @@
# notice
# warning
# error
+ # log
# fatal
# panic (effectively off)
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
- # and their durations.
+ # and their durations, > 0 logs only
+ # statements running at least N msec.
+
#silent_mode = off # DO NOT USE without syslog or
# redirect_stderr