This patch fixes the event type used to log output from the

stderr-in-service or output-from-syslogger-in-service code. Previously
everything was flagged as ERRORs there, which caused all instances to
log "LOG: logger shutting down" as error...

Please apply for 8.1. I'd also like it considered for 8.0 since logging
non-errors as errors can be cause for alarm amongst people who actually
look at their logs...

Magnus Hagander
This commit is contained in:
Bruce Momjian 2005-08-12 21:36:59 +00:00
parent 65790b9e01
commit ed63689b43

View File

@ -42,7 +42,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.161 2005/06/10 20:48:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.162 2005/08/12 21:36:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1266,6 +1266,7 @@ write_syslog(int level, const char *line)
static void static void
write_eventlog(int level, const char *line) write_eventlog(int level, const char *line)
{ {
int eventlevel = EVENTLOG_ERROR_TYPE;
static HANDLE evtHandle = INVALID_HANDLE_VALUE; static HANDLE evtHandle = INVALID_HANDLE_VALUE;
if (evtHandle == INVALID_HANDLE_VALUE) if (evtHandle == INVALID_HANDLE_VALUE)
@ -1278,8 +1279,33 @@ write_eventlog(int level, const char *line)
} }
} }
switch (level)
{
case DEBUG5:
case DEBUG4:
case DEBUG3:
case DEBUG2:
case DEBUG1:
case LOG:
case COMMERROR:
case INFO:
case NOTICE:
eventlevel = EVENTLOG_INFORMATION_TYPE;
break;
case WARNING:
eventlevel = EVENTLOG_WARNING_TYPE;
break;
case ERROR:
case FATAL:
case PANIC:
default:
eventlevel = EVENTLOG_ERROR_TYPE;
break;
}
ReportEvent(evtHandle, ReportEvent(evtHandle,
level, eventlevel,
0, 0,
0, /* All events are Id 0 */ 0, /* All events are Id 0 */
NULL, NULL,
@ -1634,32 +1660,7 @@ send_message_to_server_log(ErrorData *edata)
/* Write to eventlog, if enabled */ /* Write to eventlog, if enabled */
if (Log_destination & LOG_DESTINATION_EVENTLOG) if (Log_destination & LOG_DESTINATION_EVENTLOG)
{ {
int eventlog_level; write_eventlog(edata->elevel, buf.data);
switch (edata->elevel)
{
case DEBUG5:
case DEBUG4:
case DEBUG3:
case DEBUG2:
case DEBUG1:
case LOG:
case COMMERROR:
case INFO:
case NOTICE:
eventlog_level = EVENTLOG_INFORMATION_TYPE;
break;
case WARNING:
eventlog_level = EVENTLOG_WARNING_TYPE;
break;
case ERROR:
case FATAL:
case PANIC:
default:
eventlog_level = EVENTLOG_ERROR_TYPE;
break;
}
write_eventlog(eventlog_level, buf.data);
} }
#endif /* WIN32 */ #endif /* WIN32 */
@ -1675,7 +1676,7 @@ send_message_to_server_log(ErrorData *edata)
* because that's really a pipe to the syslogger process. * because that's really a pipe to the syslogger process.
*/ */
if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service()) if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
write_eventlog(EVENTLOG_ERROR_TYPE, buf.data); write_eventlog(edata->elevel, buf.data);
else else
#endif #endif
fprintf(stderr, "%s", buf.data); fprintf(stderr, "%s", buf.data);