diff --git a/src/backend/distributed/connection/remote_commands.c b/src/backend/distributed/connection/remote_commands.c index d9d7f2027..7c3ef2d0b 100644 --- a/src/backend/distributed/connection/remote_commands.c +++ b/src/backend/distributed/connection/remote_commands.c @@ -352,17 +352,7 @@ LogRemoteCommand(MultiConnection *connection, const char *command) return; } - if (log_min_messages <= NOTICE) - { - /* - * If the message might be written to the server log then we apply - * log redaction to avoid private data from leaking into logs - * (enterprise only). - */ - command = ApplyLogRedaction(command); - } - - ereport(NOTICE, (errmsg("issuing %s", command), + ereport(NOTICE, (errmsg("issuing %s", ApplyLogRedaction(command)), errdetail("on server %s@%s:%d connectionId: %ld", connection->user, connection->hostname, connection->port, connection->connectionId))); diff --git a/src/backend/distributed/executor/local_executor.c b/src/backend/distributed/executor/local_executor.c index e69da7edc..e9252a8b6 100644 --- a/src/backend/distributed/executor/local_executor.c +++ b/src/backend/distributed/executor/local_executor.c @@ -489,17 +489,8 @@ LogLocalCommand(const char *command) return; } - if (log_min_messages <= NOTICE) - { - /* - * If the message might be written to the server log then we apply - * log redaction to avoid private data from leaking into logs - * (enterprise only). - */ - command = ApplyLogRedaction(command); - } - - ereport(NOTICE, (errmsg("executing the command locally: %s", command))); + ereport(NOTICE, (errmsg("executing the command locally: %s", + ApplyLogRedaction(command)))); } diff --git a/src/backend/distributed/test/deparse_shard_query.c b/src/backend/distributed/test/deparse_shard_query.c index 5023e646a..fa31845db 100644 --- a/src/backend/distributed/test/deparse_shard_query.c +++ b/src/backend/distributed/test/deparse_shard_query.c @@ -72,7 +72,7 @@ deparse_shard_query_test(PG_FUNCTION_ARGS) deparse_shard_query(query, InvalidOid, 0, buffer); - elog(INFO, "query: %s", ApplyLogRedaction(buffer->data)); + elog(INFO, "query: %s", buffer->data); } } diff --git a/src/backend/distributed/utils/log_utils.c b/src/backend/distributed/utils/log_utils.c index ac4ba2805..9ee75dcda 100644 --- a/src/backend/distributed/utils/log_utils.c +++ b/src/backend/distributed/utils/log_utils.c @@ -26,10 +26,10 @@ IsLoggableLevel(int logLevel) /* - * ApplyLogRedaction is only supported in Citus Enterprise + * HashLogMessage is only supported in Citus Enterprise */ char * -ApplyLogRedaction(const char *logText) +HashLogMessage(const char *logText) { return (char *) logText; } diff --git a/src/include/distributed/log_utils.h b/src/include/distributed/log_utils.h index 004f00831..f69bd27ec 100644 --- a/src/include/distributed/log_utils.h +++ b/src/include/distributed/log_utils.h @@ -9,7 +9,22 @@ #ifndef LOG_UTILS_H #define LOG_UTILS_H + +#include "utils/guc.h" + + extern bool IsLoggableLevel(int logLevel); -extern char * ApplyLogRedaction(const char *text); +extern char * HashLogMessage(const char *text); + +#define ApplyLogRedaction(text) \ + (log_min_messages <= ereport_loglevel ? HashLogMessage(text) : text) + +#undef ereport +#define ereport(elevel, rest) \ + do { \ + int ereport_loglevel = elevel; \ + (void) (ereport_loglevel); \ + ereport_domain(elevel, TEXTDOMAIN, rest); \ + } while (0) #endif /* LOG_UTILS_H */