summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 02:05:14 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 02:18:46 +0100
commite2cc6eca73cd1df8be552d7c23f9ff3d69c06f1e (patch)
tree874e0dac2d1426e44c3e748734cbb297f3feefa8 /src/shared
parent6c861f0aeff9449ee1201bb56f89861921e41c45 (diff)
log: fix order of log_unit_struct() to match other logging calls
Also, while we are at it, introduce some syntactic sugar for creating ERRNO= and MESSAGE= structured logging fields.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/conf-parser.c8
-rw-r--r--src/shared/log.h5
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);