Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09c1baa

Browse files
committed
Move code that places LOG error level between ERROR and PANIC into new
function is_log_level_output(), for code clarity.
1 parent 92b8d17 commit 09c1baa

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

src/backend/utils/error/elog.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.179 2007/01/05 22:19:43 momjian Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.180 2007/01/20 14:45:35 momjian Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -121,6 +121,7 @@ static char *expand_fmt_string(const char *fmt, ErrorData *edata);
121121
static const char *useful_strerror(int errnum);
122122
static const char *error_severity(int elevel);
123123
static void append_with_tabs(StringInfo buf, const char *str);
124+
static int is_log_level_output(int elevel, int log_min_level);
124125

125126

126127
/*
@@ -139,7 +140,7 @@ errstart(int elevel, const char *filename, int lineno,
139140
const char *funcname)
140141
{
141142
ErrorData *edata;
142-
bool output_to_server = false;
143+
bool output_to_server;
143144
bool output_to_client = false;
144145
int i;
145146

@@ -196,33 +197,10 @@ errstart(int elevel, const char *filename, int lineno,
196197

197198
/* Determine whether message is enabled for server log output */
198199
if (IsPostmasterEnvironment)
199-
{
200-
/* Complicated because LOG is sorted out-of-order for this purpose */
201-
if (elevel == LOG || elevel == COMMERROR)
202-
{
203-
if (log_min_messages == LOG)
204-
output_to_server = true;
205-
else if (log_min_messages < FATAL)
206-
output_to_server = true;
207-
}
208-
else
209-
{
210-
/* elevel != LOG */
211-
if (log_min_messages == LOG)
212-
{
213-
if (elevel >= FATAL)
214-
output_to_server = true;
215-
}
216-
/* Neither is LOG */
217-
else if (elevel >= log_min_messages)
218-
output_to_server = true;
219-
}
220-
}
200+
output_to_server = is_log_level_output(elevel, log_min_messages);
221201
else
222-
{
223202
/* In bootstrap/standalone case, do not sort LOG out-of-order */
224203
output_to_server = (elevel >= log_min_messages);
225-
}
226204

227205
/* Determine whether message is enabled for client output */
228206
if (whereToSendOutput == DestRemote && elevel != COMMERROR)
@@ -2073,3 +2051,28 @@ write_stderr(const char *fmt,...)
20732051
#endif
20742052
va_end(ap);
20752053
}
2054+
2055+
2056+
static int is_log_level_output(int elevel, int log_min_level)
2057+
{
2058+
/*
2059+
* Complicated because LOG is sorted out-of-order here, between
2060+
* ERROR and FATAL.
2061+
*/
2062+
if (elevel == LOG || elevel == COMMERROR)
2063+
{
2064+
if (log_min_level == LOG || log_min_level <= ERROR)
2065+
return true;
2066+
}
2067+
else if (log_min_level == LOG)
2068+
{
2069+
/* elevel != LOG */
2070+
if (elevel >= FATAL)
2071+
return true;
2072+
}
2073+
/* Neither is LOG */
2074+
else if (elevel >= log_min_level)
2075+
return true;
2076+
2077+
return false;
2078+
}

0 commit comments

Comments
 (0)