diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/log.c | 19 | ||||
-rw-r--r-- | src/shared/log.h | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/shared/log.c b/src/shared/log.c index e8b63a3ed9..6168a2955d 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -693,7 +693,8 @@ int log_object_internalv( va_list ap) { PROTECT_ERRNO; - char buffer[LINE_MAX]; + char *buffer, *b; + size_t l; if (error < 0) error = -error; @@ -705,7 +706,21 @@ int log_object_internalv( if (error != 0) errno = error; - vsnprintf(buffer, sizeof(buffer), format, ap); + /* Prepend the object name before the message */ + if (object) { + size_t n; + + n = strlen(object); + l = n + 2 + LINE_MAX; + + buffer = newa(char, l); + b = stpcpy(stpcpy(buffer, object), ": "); + } else { + l = LINE_MAX; + b = buffer = newa(char, l); + } + + vsnprintf(b, l, format, ap); return log_dispatch(level, error, file, line, func, object_field, object, buffer); } diff --git a/src/shared/log.h b/src/shared/log.h index 09d2fc767b..569762d083 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -204,7 +204,6 @@ LogTarget log_target_from_string(const char *s) _pure_; /* 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", abs(error) void log_received_signal(int level, const struct signalfd_siginfo *si); |