mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Remove am_syslogger global variable
Use the new MyBackendType instead. More similar changes for other "am something" variables are possible. This one was just particularly simple. Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com
This commit is contained in:
@ -74,11 +74,6 @@ char *Log_filename = NULL;
|
|||||||
bool Log_truncate_on_rotation = false;
|
bool Log_truncate_on_rotation = false;
|
||||||
int Log_file_mode = S_IRUSR | S_IWUSR;
|
int Log_file_mode = S_IRUSR | S_IWUSR;
|
||||||
|
|
||||||
/*
|
|
||||||
* Globally visible state (used by elog.c)
|
|
||||||
*/
|
|
||||||
bool am_syslogger = false;
|
|
||||||
|
|
||||||
extern bool redirection_done;
|
extern bool redirection_done;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -177,8 +172,6 @@ SysLoggerMain(int argc, char *argv[])
|
|||||||
syslogger_parseArgs(argc, argv);
|
syslogger_parseArgs(argc, argv);
|
||||||
#endif /* EXEC_BACKEND */
|
#endif /* EXEC_BACKEND */
|
||||||
|
|
||||||
am_syslogger = true;
|
|
||||||
|
|
||||||
MyBackendType = B_LOGGER;
|
MyBackendType = B_LOGGER;
|
||||||
init_ps_display(NULL);
|
init_ps_display(NULL);
|
||||||
|
|
||||||
@ -1078,7 +1071,7 @@ flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer)
|
|||||||
/*
|
/*
|
||||||
* Write text to the currently open logfile
|
* Write text to the currently open logfile
|
||||||
*
|
*
|
||||||
* This is exported so that elog.c can call it when am_syslogger is true.
|
* This is exported so that elog.c can call it when MyBackendType is B_LOGGER.
|
||||||
* This allows the syslogger process to record elog messages of its own,
|
* This allows the syslogger process to record elog messages of its own,
|
||||||
* even though its stderr does not point at the syslog pipe.
|
* even though its stderr does not point at the syslog pipe.
|
||||||
*/
|
*/
|
||||||
|
@ -2923,7 +2923,7 @@ write_csvlog(ErrorData *edata)
|
|||||||
appendStringInfoChar(&buf, '\n');
|
appendStringInfoChar(&buf, '\n');
|
||||||
|
|
||||||
/* If in the syslogger process, try to write messages direct to file */
|
/* If in the syslogger process, try to write messages direct to file */
|
||||||
if (am_syslogger)
|
if (MyBackendType == B_LOGGER)
|
||||||
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
|
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
|
||||||
else
|
else
|
||||||
write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
|
write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
|
||||||
@ -3117,7 +3117,7 @@ send_message_to_server_log(ErrorData *edata)
|
|||||||
* catching stderr output, and we are not ourselves the syslogger.
|
* catching stderr output, and we are not ourselves the syslogger.
|
||||||
* Otherwise, just do a vanilla write to stderr.
|
* Otherwise, just do a vanilla write to stderr.
|
||||||
*/
|
*/
|
||||||
if (redirection_done && !am_syslogger)
|
if (redirection_done && MyBackendType != B_LOGGER)
|
||||||
write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_STDERR);
|
write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_STDERR);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
@ -3136,13 +3136,13 @@ send_message_to_server_log(ErrorData *edata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If in the syslogger process, try to write messages direct to file */
|
/* If in the syslogger process, try to write messages direct to file */
|
||||||
if (am_syslogger)
|
if (MyBackendType == B_LOGGER)
|
||||||
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);
|
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);
|
||||||
|
|
||||||
/* Write to CSV log if enabled */
|
/* Write to CSV log if enabled */
|
||||||
if (Log_destination & LOG_DESTINATION_CSVLOG)
|
if (Log_destination & LOG_DESTINATION_CSVLOG)
|
||||||
{
|
{
|
||||||
if (redirection_done || am_syslogger)
|
if (redirection_done || MyBackendType == B_LOGGER)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* send CSV data if it's safe to do so (syslogger doesn't need the
|
* send CSV data if it's safe to do so (syslogger doesn't need the
|
||||||
|
@ -70,8 +70,6 @@ extern PGDLLIMPORT char *Log_filename;
|
|||||||
extern bool Log_truncate_on_rotation;
|
extern bool Log_truncate_on_rotation;
|
||||||
extern int Log_file_mode;
|
extern int Log_file_mode;
|
||||||
|
|
||||||
extern bool am_syslogger;
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
extern int syslogPipe[2];
|
extern int syslogPipe[2];
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user