From 09c1baabc3c6a6c208bd8de0c92a50b7ffebc786 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 20 Jan 2007 14:45:35 +0000 Subject: [PATCH] Move code that places LOG error level between ERROR and PANIC into new function is_log_level_output(), for code clarity. --- src/backend/utils/error/elog.c | 55 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b8a4846c3f..45bd0998b8 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.179 2007/01/05 22:19:43 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.180 2007/01/20 14:45:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,6 +121,7 @@ static char *expand_fmt_string(const char *fmt, ErrorData *edata); static const char *useful_strerror(int errnum); static const char *error_severity(int elevel); static void append_with_tabs(StringInfo buf, const char *str); +static int is_log_level_output(int elevel, int log_min_level); /* @@ -139,7 +140,7 @@ errstart(int elevel, const char *filename, int lineno, const char *funcname) { ErrorData *edata; - bool output_to_server = false; + bool output_to_server; bool output_to_client = false; int i; @@ -196,33 +197,10 @@ errstart(int elevel, const char *filename, int lineno, /* Determine whether message is enabled for server log output */ if (IsPostmasterEnvironment) - { - /* Complicated because LOG is sorted out-of-order for this purpose */ - if (elevel == LOG || elevel == COMMERROR) - { - if (log_min_messages == LOG) - output_to_server = true; - else if (log_min_messages < FATAL) - output_to_server = true; - } - else - { - /* elevel != LOG */ - if (log_min_messages == LOG) - { - if (elevel >= FATAL) - output_to_server = true; - } - /* Neither is LOG */ - else if (elevel >= log_min_messages) - output_to_server = true; - } - } + output_to_server = is_log_level_output(elevel, log_min_messages); else - { /* In bootstrap/standalone case, do not sort LOG out-of-order */ output_to_server = (elevel >= log_min_messages); - } /* Determine whether message is enabled for client output */ if (whereToSendOutput == DestRemote && elevel != COMMERROR) @@ -2073,3 +2051,28 @@ write_stderr(const char *fmt,...) #endif va_end(ap); } + + +static int 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) + return true; + } + else if (log_min_level == LOG) + { + /* elevel != LOG */ + if (elevel >= FATAL) + return true; + } + /* Neither is LOG */ + else if (elevel >= log_min_level) + return true; + + return false; +} -- 2.40.0