mirror of https://github.com/citusdata/citus.git
Make ApplyLogRedaction a macro and redefine ereport
parent
06709ee108
commit
f1a0582973
|
@ -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)));
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue