Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 66229ac

Browse files
committed
Introduce a LOG_SERVER_ONLY ereport level, which is never sent to client.
This elevel is useful for logging audit messages and similar information that should not be passed to the client. It's equivalent to LOG in terms of decisions about logging priority in the postmaster log, but messages with this elevel will never be sent to the client. In the current implementation, it's just an alias for the longstanding COMMERROR elevel (or more accurately, we've made COMMERROR an alias for this). At some point it might be interesting to allow a LOG_ONLY flag to be attached to any elevel, but that would be considerably more complicated, and it's not clear there's enough use-cases to justify the extra work. For now, let's just take the easy 90% solution. David Steele, reviewed by Fabien Coelho, Petr Jelínek, and myself
1 parent 58666ed commit 66229ac

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/backend/utils/error/elog.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ errstart(int elevel, const char *filename, int lineno,
293293
output_to_server = is_log_level_output(elevel, log_min_messages);
294294

295295
/* Determine whether message is enabled for client output */
296-
if (whereToSendOutput == DestRemote && elevel != COMMERROR)
296+
if (whereToSendOutput == DestRemote && elevel != LOG_SERVER_ONLY)
297297
{
298298
/*
299299
* client_min_messages is honored only after we complete the
@@ -2086,7 +2086,7 @@ write_eventlog(int level, const char *line, int len)
20862086
case DEBUG2:
20872087
case DEBUG1:
20882088
case LOG:
2089-
case COMMERROR:
2089+
case LOG_SERVER_ONLY:
20902090
case INFO:
20912091
case NOTICE:
20922092
eventlevel = EVENTLOG_INFORMATION_TYPE;
@@ -2965,7 +2965,7 @@ send_message_to_server_log(ErrorData *edata)
29652965
syslog_level = LOG_DEBUG;
29662966
break;
29672967
case LOG:
2968-
case COMMERROR:
2968+
case LOG_SERVER_ONLY:
29692969
case INFO:
29702970
syslog_level = LOG_INFO;
29712971
break;
@@ -3595,7 +3595,7 @@ error_severity(int elevel)
35953595
prefix = _("DEBUG");
35963596
break;
35973597
case LOG:
3598-
case COMMERROR:
3598+
case LOG_SERVER_ONLY:
35993599
prefix = _("LOG");
36003600
break;
36013601
case INFO:
@@ -3699,7 +3699,7 @@ write_stderr(const char *fmt,...)
36993699
static bool
37003700
is_log_level_output(int elevel, int log_min_level)
37013701
{
3702-
if (elevel == LOG || elevel == COMMERROR)
3702+
if (elevel == LOG || elevel == LOG_SERVER_ONLY)
37033703
{
37043704
if (log_min_level == LOG || log_min_level <= ERROR)
37053705
return true;

src/include/utils/elog.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
#define DEBUG1 14 /* used by GUC debug_* variables */
2626
#define LOG 15 /* Server operational messages; sent only to
2727
* server log by default. */
28-
#define COMMERROR 16 /* Client communication problems; same as LOG
29-
* for server reporting, but never sent to
30-
* client. */
28+
#define LOG_SERVER_ONLY 16 /* Same as LOG for server reporting, but never
29+
* sent to client. */
30+
#define COMMERROR LOG_SERVER_ONLY /* Client communication problems; same
31+
* as LOG for server reporting, but
32+
* never sent to client. */
3133
#define INFO 17 /* Messages specifically requested by user (eg
3234
* VACUUM VERBOSE output); always sent to
3335
* client regardless of client_min_messages,
@@ -354,7 +356,7 @@ typedef struct ErrorData
354356
char *detail_log; /* detail error message for server log only */
355357
char *hint; /* hint message */
356358
char *context; /* context message */
357-
const char *message_id; /* message id of .message (original English text) */
359+
const char *message_id; /* primary message's id (original string) */
358360
char *schema_name; /* name of schema */
359361
char *table_name; /* name of table */
360362
char *column_name; /* name of column */

0 commit comments

Comments
 (0)