mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 23:26:30 +00:00
Add log_hint() function for logging hints
There are a few places where additional hints are written as log output, usually LOG_NOTICE. Create an explicit function to provide hints in a standardized manner; by storing the log level of the previous logger call, we can ensure the hint is only displayed when the log message itself would be. Part of an ongoing effort to better control repmgr's logging output.
This commit is contained in:
18
log.c
18
log.c
@@ -44,7 +44,7 @@ static int detect_log_facility(const char *facility);
|
||||
|
||||
int log_type = REPMGR_STDERR;
|
||||
int log_level = LOG_NOTICE;
|
||||
|
||||
int last_log_level = LOG_NOTICE;
|
||||
|
||||
void
|
||||
stderr_log_with_level(const char *level_name, int level, const char *fmt, ...)
|
||||
@@ -54,6 +54,12 @@ stderr_log_with_level(const char *level_name, int level, const char *fmt, ...)
|
||||
char buff[100];
|
||||
va_list ap;
|
||||
|
||||
/*
|
||||
* Store the requested level so that if there's a subsequent
|
||||
* log_hint(), we can suppress that if appropriate.
|
||||
*/
|
||||
last_log_level = level;
|
||||
|
||||
if (log_level >= level)
|
||||
{
|
||||
time(&t);
|
||||
@@ -69,6 +75,16 @@ stderr_log_with_level(const char *level_name, int level, const char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
log_hint(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
stderr_log_with_level("HINT", last_log_level, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
logger_init(t_configuration_options * opts, const char *ident, const char *level, const char *facility)
|
||||
|
||||
Reference in New Issue
Block a user