diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/conf-parser.c | 8 | ||||
-rw-r--r-- | src/shared/log.h | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 6bd9d9ebf7..f9a3459caa 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -64,19 +64,19 @@ int log_syntax_internal( error > 0 ? error : EINVAL, file, line, func, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, - MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR), + LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR), "CONFIG_FILE=%s", config_file, "CONFIG_LINE=%u", config_line, - "MESSAGE=[%s:%u] %s", config_file, config_line, msg, + LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg), NULL); else r = log_struct_internal(level, error > 0 ? error : EINVAL, file, line, func, - MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR), + LOG_MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR), "CONFIG_FILE=%s", config_file, "CONFIG_LINE=%u", config_line, - "MESSAGE=[%s:%u] %s", config_file, config_line, msg, + LOG_MESSAGE("[%s:%u] %s", config_file, config_line, msg), NULL); return r; diff --git a/src/shared/log.h b/src/shared/log.h index 278010432d..3a4d1134a1 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -199,7 +199,10 @@ bool log_on_console(void) _pure_; const char *log_target_to_string(LogTarget target) _const_; LogTarget log_target_from_string(const char *s) _pure_; -#define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x) +/* Helpers to prepare various fields for structured logging */ +#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__ +#define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x) +#define LOG_ERRNO(error) "ERRNO=%i", error void log_received_signal(int level, const struct signalfd_siginfo *si); |