agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Álvaro Herrera <[email protected]>
Subject: [PATCH] POC: syslogger: add Boolean state indicating readiness
Date: Tue, 26 May 2026 12:45:01 +0200
This replaces a comparison of MyBackendType, which was made obsolete by
commit 0c8e082fba8d.
---
src/backend/postmaster/syslogger.c | 5 +++++
src/backend/utils/error/elog.c | 6 +++---
src/include/postmaster/syslogger.h | 1 +
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index acfe0a01715..d736f6a4fab 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -76,6 +76,9 @@ char *Log_filename = NULL;
bool Log_truncate_on_rotation = false;
int Log_file_mode = S_IRUSR | S_IWUSR;
+/* for elog.c */
+bool syslogger_setup_done = false;
+
/*
* Private state
*/
@@ -195,6 +198,8 @@ SysLoggerMain(const void *startup_data, size_t startup_data_len)
Assert(startup_data_len == 0);
#endif
+ syslogger_setup_done = true;
+
/*
* Now that we're done reading the startup data, release postmaster's
* working memory context.
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 50c53b571a0..a6936a0c664 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -3831,7 +3831,7 @@ send_message_to_server_log(ErrorData *edata)
* pipe). If this is not possible, fallback to an entry written to
* stderr.
*/
- if (redirection_done || MyBackendType == B_LOGGER)
+ if (redirection_done || syslogger_setup_done)
write_csvlog(edata);
else
fallback_to_stderr = true;
@@ -3845,7 +3845,7 @@ send_message_to_server_log(ErrorData *edata)
* pipe). If this is not possible, fallback to an entry written to
* stderr.
*/
- if (redirection_done || MyBackendType == B_LOGGER)
+ if (redirection_done || syslogger_setup_done)
{
write_jsonlog(edata);
}
@@ -3885,7 +3885,7 @@ send_message_to_server_log(ErrorData *edata)
}
/* If in the syslogger process, try to write messages direct to file */
- if (MyBackendType == B_LOGGER)
+ if (syslogger_setup_done)
write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);
/* No more need of the message formatted for stderr */
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 30c4b2daf3f..44409fc2542 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -85,6 +85,7 @@ extern PGDLLIMPORT int syslogPipe[2];
extern PGDLLIMPORT HANDLE syslogPipe[2];
#endif
+extern bool syslogger_setup_done;
extern int SysLogger_Start(int child_slot);
--
2.47.3
--oji7a74ejnbtd35k--
view thread (490+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] POC: syslogger: add Boolean state indicating readiness
In-Reply-To: <no-message-id-301831@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox