summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2020-03-11 15:36:40 +0000
committerPeter Eisentraut2020-03-13 13:01:15 +0000
commitd90bd24391fdde2b73906e16052821c9e3c1ce82 (patch)
tree9fec4ece2b14ce9221752540c5740022d0c95fa7
parent8e8a0becb335529c66a9f82f88e1419e49b458ae (diff)
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 <[email protected]> Reviewed-by: Kuntal Ghosh <[email protected]> Reviewed-by: Alvaro Herrera <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
-rw-r--r--src/backend/postmaster/syslogger.c9
-rw-r--r--src/backend/utils/error/elog.c8
-rw-r--r--src/include/postmaster/syslogger.h2
3 files changed, 5 insertions, 14 deletions
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 3b708c3f67..ffcb54968f 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -74,11 +74,6 @@ char *Log_filename = NULL;
bool Log_truncate_on_rotation = false;
int Log_file_mode = S_IRUSR | S_IWUSR;
-/*
- * Globally visible state (used by elog.c)
- */
-bool am_syslogger = false;
-
extern bool redirection_done;
/*
@@ -177,8 +172,6 @@ SysLoggerMain(int argc, char *argv[])
syslogger_parseArgs(argc, argv);
#endif /* EXEC_BACKEND */
- am_syslogger = true;
-
MyBackendType = B_LOGGER;
init_ps_display(NULL);
@@ -1078,7 +1071,7 @@ flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer)
/*
* 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,
* even though its stderr does not point at the syslog pipe.
*/
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index f5b0211f66..f8ae94729c 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2923,7 +2923,7 @@ write_csvlog(ErrorData *edata)
appendStringInfoChar(&buf, '\n');
/* 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);
else
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.
* 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);
#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 (am_syslogger)
+ if (MyBackendType == B_LOGGER)
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);
/* Write to CSV log if enabled */
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
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 9b7a386dbd..f611bd1411 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -70,8 +70,6 @@ extern PGDLLIMPORT char *Log_filename;
extern bool Log_truncate_on_rotation;
extern int Log_file_mode;
-extern bool am_syslogger;
-
#ifndef WIN32
extern int syslogPipe[2];
#else