From: Lennart Poettering Date: Mon, 27 Feb 2023 14:47:11 +0000 (+0100) Subject: journald: always pass error code to logging function, even if we don't use it with %m X-Git-Tag: v254-rc1~1148^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32b0678c868b42ad68d383c8bf18fc2cdb1fbe95;p=thirdparty%2Fsystemd.git journald: always pass error code to logging function, even if we don't use it with %m We always want to pass the error code along with the log call, so that it can add it to structured logging, even if the format string does not contain %m. --- diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 1c7372e6285..a6741ff8cc4 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -836,7 +836,7 @@ static bool shall_try_append_again(JournalFile *f, int r) { case -EFBIG: /* Hit fs limit */ case -EDQUOT: /* Quota limit hit */ case -ENOSPC: /* Disk full */ - log_debug("%s: Allocation limit reached, rotating.", f->path); + log_debug_errno(r, "%s: Allocation limit reached, rotating.", f->path); return true; case -EROFS: /* Read-only file system */ @@ -844,53 +844,53 @@ static bool shall_try_append_again(JournalFile *f, int r) { * rotated. If the FS is read-only, rotation will fail and s->system_journal will be set to * NULL. After that, when find_journal will try to open the journal since s->system_journal * will be NULL, it will open the runtime journal. */ - log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Read-only file system, rotating.", f->path); + log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Read-only file system, rotating.", f->path); return true; case -EIO: /* I/O error of some kind (mmap) */ - log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: IO error, rotating.", f->path); + log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "%s: IO error, rotating.", f->path); return true; case -EHOSTDOWN: /* Other machine */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Journal file from other machine, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Journal file from other machine, rotating.", f->path); return true; case -EBUSY: /* Unclean shutdown */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Unclean shutdown, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Unclean shutdown, rotating.", f->path); return true; case -EPROTONOSUPPORT: /* Unsupported feature */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Unsupported feature, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Unsupported feature, rotating.", f->path); return true; case -EBADMSG: /* Corrupted */ case -ENODATA: /* Truncated */ case -ESHUTDOWN: /* Already archived */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Journal file corrupted, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Journal file corrupted, rotating.", f->path); return true; case -EIDRM: /* Journal file has been deleted */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Journal file has been deleted, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Journal file has been deleted, rotating.", f->path); return true; case -EREMCHG: /* Wallclock time (CLOCK_REALTIME) jumped backwards relative to last journal entry */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Realtime clock jumped backwards relative to last journal entry, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Realtime clock jumped backwards relative to last journal entry, rotating.", f->path); return true; case -EREMOTE: /* Boot ID different from the one of the last entry */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Boot ID changed since last record, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Boot ID changed since last record, rotating.", f->path); return true; case -ENOTNAM: /* Monotonic time (CLOCK_MONOTONIC) jumped backwards relative to last journal entry */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Monotonic clock jumped backwards relative to last journal entry, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Monotonic clock jumped backwards relative to last journal entry, rotating.", f->path); return true; case -EILSEQ: /* seqnum ID last used in the file doesn't match the one we'd passed when writing an entry to it */ - log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Journal file uses a different sequence number ID, rotating.", f->path); + log_ratelimit_info_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Journal file uses a different sequence number ID, rotating.", f->path); return true; case -EAFNOSUPPORT: - log_ratelimit_error(JOURNAL_LOG_RATELIMIT, "%s: Underlying file system does not support memory mapping or another required file system feature.", f->path); + log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "%s: Underlying file system does not support memory mapping or another required file system feature.", f->path); return false; default: