]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: Remove log_ratelimit_debug() macros
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 17 Nov 2022 09:25:06 +0000 (10:25 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 17 Nov 2022 13:16:18 +0000 (22:16 +0900)
These don't make sense anymore since we disable log ratelimiting
when logging at debug level.

src/basic/log.h
src/journal/journald-audit.c
src/journal/journald-console.c
src/journal/journald-kmsg.c
src/journal/journald-native.c
src/journal/journald-server.c
src/journal/journald-syslog.c
src/journal/journald-wall.c

index 040b7eb07b667525e9b1aacc79a72e179dc8bdda..2b1ac5f8c640a4881db4e806c69e35b0ec9ddf59 100644 (file)
@@ -408,7 +408,6 @@ typedef struct LogRateLimit {
         log_ratelimit_full_errno(level, 0, _ratelimit, format, ##__VA_ARGS__)
 
 /* Normal logging */
-#define log_ratelimit_debug(...)     log_ratelimit_full(LOG_DEBUG,   __VA_ARGS__)
 #define log_ratelimit_info(...)      log_ratelimit_full(LOG_INFO,    __VA_ARGS__)
 #define log_ratelimit_notice(...)    log_ratelimit_full(LOG_NOTICE,  __VA_ARGS__)
 #define log_ratelimit_warning(...)   log_ratelimit_full(LOG_WARNING, __VA_ARGS__)
@@ -416,7 +415,6 @@ typedef struct LogRateLimit {
 #define log_ratelimit_emergency(...) log_ratelimit_full(log_emergency_level(), __VA_ARGS__)
 
 /* Logging triggered by an errno-like error */
-#define log_ratelimit_debug_errno(error, ...)     log_ratelimit_full_errno(LOG_DEBUG,   error, __VA_ARGS__)
 #define log_ratelimit_info_errno(error, ...)      log_ratelimit_full_errno(LOG_INFO,    error, __VA_ARGS__)
 #define log_ratelimit_notice_errno(error, ...)    log_ratelimit_full_errno(LOG_NOTICE,  error, __VA_ARGS__)
 #define log_ratelimit_warning_errno(error, ...)   log_ratelimit_full_errno(LOG_WARNING, error, __VA_ARGS__)
index 557dfdb7b62fa5f4862f9f2fdd82e8652566fe96..d301d2896621d981231bcb1973cb630be302fc20 100644 (file)
@@ -264,8 +264,7 @@ static int map_all_fields(
                 const char *v;
 
                 if (*n >= m) {
-                        log_ratelimit_debug(
-                                JOURNALD_LOG_RATELIMIT,
+                        log_debug(
                                 "More fields in audit message than audit field limit (%i), skipping remaining fields",
                                 N_IOVEC_AUDIT_FIELDS);
                         return 0;
@@ -310,8 +309,7 @@ static int map_all_fields(
 
                         r = mf->map(mf->journal_field, &v, iovec, n);
                         if (r < 0)
-                                return log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT,
-                                                                 "Failed to parse audit array: %m");
+                                return log_debug_errno(r, "Failed to parse audit array: %m");
 
                         if (r > 0) {
                                 mapped = true;
@@ -323,8 +321,7 @@ static int map_all_fields(
                 if (!mapped) {
                         r = map_generic_field(prefix, &p, iovec, n);
                         if (r < 0)
-                                return log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT,
-                                                                 "Failed to parse audit array: %m");
+                                return log_debug_errno(r, "Failed to parse audit array: %m");
 
                         if (r == 0)
                                 /* Couldn't process as generic field, let's just skip over it */
@@ -434,12 +431,12 @@ void server_process_audit_message(
             salen != sizeof(struct sockaddr_nl) ||
             sa->nl.nl_family != AF_NETLINK ||
             sa->nl.nl_pid != 0) {
-                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Audit netlink message from invalid sender.");
+                log_debug("Audit netlink message from invalid sender.");
                 return;
         }
 
         if (!ucred || ucred->pid != 0) {
-                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Audit netlink message with invalid credentials.");
+                log_debug("Audit netlink message with invalid credentials.");
                 return;
         }
 
index 40a740ca4019514504c23fa9b8bf18068450c1e7..2035e2d9b6962cd9a3fb8d71347b7928cb31bf97 100644 (file)
@@ -94,10 +94,10 @@ void server_forward_console(
 
         fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
         if (fd < 0) {
-                log_ratelimit_debug_errno(fd, JOURNALD_LOG_RATELIMIT, "Failed to open %s for logging: %m", tty);
+                log_debug_errno(fd, "Failed to open %s for logging: %m", tty);
                 return;
         }
 
         if (writev(fd, iovec, n) < 0)
-                log_ratelimit_debug_errno(errno, JOURNALD_LOG_RATELIMIT, "Failed to write to %s for logging: %m", tty);
+                log_debug_errno(errno, "Failed to write to %s for logging: %m", tty);
 }
index b711df455772d46e1d7c7fb732c0598f283c6531..6c1e7892d1cb2b4f3810dd86bd80b9da1bcc85a5 100644 (file)
@@ -80,8 +80,7 @@ void server_forward_kmsg(
         iovec[n++] = IOVEC_MAKE_STRING("\n");
 
         if (writev(s->dev_kmsg_fd, iovec, n) < 0)
-                log_ratelimit_debug_errno(errno, JOURNALD_LOG_RATELIMIT,
-                                          "Failed to write to /dev/kmsg for logging: %m");
+                log_debug_errno(errno, "Failed to write to /dev/kmsg for logging: %m");
 }
 
 static bool is_us(const char *identifier, const char *pid) {
@@ -348,7 +347,7 @@ int server_flush_dev_kmsg(Server *s) {
         if (!s->dev_kmsg_readable)
                 return 0;
 
-        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Flushing /dev/kmsg...");
+        log_debug("Flushing /dev/kmsg...");
 
         for (;;) {
                 r = server_read_dev_kmsg(s);
index 1d2cb0b71ac2e6d3b85a59ec997e5d26de903a52..21e20db2d44f033690dcff7c170a40d12ba96150 100644 (file)
@@ -122,8 +122,7 @@ static int server_process_entry(
 
                 if (!e) {
                         /* Trailing noise, let's ignore it, and flush what we collected */
-                        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                            "Received message with trailing noise, ignoring.");
+                        log_debug("Received message with trailing noise, ignoring.");
                         break; /* finish processing of the message */
                 }
 
@@ -142,8 +141,7 @@ static int server_process_entry(
 
                 /* A property follows */
                 if (n > ENTRY_FIELD_COUNT_MAX) {
-                        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                            "Received an entry that has more than " STRINGIFY(ENTRY_FIELD_COUNT_MAX) " fields, ignoring entry.");
+                        log_debug("Received an entry that has more than " STRINGIFY(ENTRY_FIELD_COUNT_MAX) " fields, ignoring entry.");
                         goto finish;
                 }
 
@@ -163,15 +161,13 @@ static int server_process_entry(
 
                                 l = e - p;
                                 if (l > DATA_SIZE_MAX) {
-                                        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                            "Received text block of %zu bytes is too large, ignoring entry.", l);
+                                        log_debug("Received text block of %zu bytes is too large, ignoring entry.", l);
                                         goto finish;
                                 }
 
                                 if (entry_size + l + n + 1 > ENTRY_SIZE_MAX) { /* data + separators + trailer */
-                                        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                            "Entry is too big (%zu bytes after processing %zu entries), ignoring entry.",
-                                                            entry_size + l, n + 1);
+                                        log_debug("Entry is too big (%zu bytes after processing %zu entries), ignoring entry.",
+                                                  entry_size + l, n + 1);
                                         goto finish;
                                 }
 
@@ -195,31 +191,26 @@ static int server_process_entry(
                         char *k;
 
                         if (*remaining < e - p + 1 + sizeof(uint64_t) + 1) {
-                                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                    "Failed to parse message, ignoring.");
+                                log_debug("Failed to parse message, ignoring.");
                                 break;
                         }
 
                         l = unaligned_read_le64(e + 1);
                         if (l > DATA_SIZE_MAX) {
-                                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                    "Received binary data block of %"PRIu64" bytes is too large, ignoring entry.",
-                                                    l);
+                                log_debug("Received binary data block of %"PRIu64" bytes is too large, ignoring entry.", l);
                                 goto finish;
                         }
 
                         total = (e - p) + 1 + l;
                         if (entry_size + total + n + 1 > ENTRY_SIZE_MAX) { /* data + separators + trailer */
-                                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                    "Entry is too big (%"PRIu64"bytes after processing %zu fields), ignoring.",
-                                                    entry_size + total, n + 1);
+                                log_debug("Entry is too big (%"PRIu64"bytes after processing %zu fields), ignoring.",
+                                          entry_size + total, n + 1);
                                 goto finish;
                         }
 
                         if ((uint64_t) *remaining < e - p + 1 + sizeof(uint64_t) + l + 1 ||
                             e[1+sizeof(uint64_t)+l] != '\n') {
-                                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                    "Failed to parse message, ignoring.");
+                                log_debug("Failed to parse message, ignoring.");
                                 break;
                         }
 
@@ -259,9 +250,7 @@ static int server_process_entry(
         entry_size += STRLEN("_TRANSPORT=journal");
 
         if (entry_size + n + 1 > ENTRY_SIZE_MAX) { /* data + separators + trailer */
-                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                    "Entry is too big with %zu properties and %zu bytes, ignoring.",
-                                    n, entry_size);
+                log_debug("Entry is too big with %zu properties and %zu bytes, ignoring.", n, entry_size);
                 goto finish;
         }
 
index 3c49d9fa318a7498b6486a2c36cce648334faad8..e86aa481d93e5c01628d304eda51b37ccf9e72dd 100644 (file)
@@ -118,8 +118,7 @@ static int determine_path_usage(
                         continue;
 
                 if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0) {
-                        log_ratelimit_debug_errno(errno, JOURNALD_LOG_RATELIMIT,
-                                                 "Failed to stat %s/%s, ignoring: %m", path, de->d_name);
+                        log_debug_errno(errno, "Failed to stat %s/%s, ignoring: %m", path, de->d_name);
                         continue;
                 }
 
@@ -591,9 +590,7 @@ static int vacuum_offline_user_journals(Server *s) {
 
                 r = parse_uid(u, &uid);
                 if (r < 0) {
-                        log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT,
-                                                  "Failed to parse UID from file name '%s', ignoring: %m",
-                                                  de->d_name);
+                        log_debug_errno(r, "Failed to parse UID from file name '%s', ignoring: %m", de->d_name);
                         continue;
                 }
 
@@ -641,8 +638,7 @@ static int vacuum_offline_user_journals(Server *s) {
                                                             "Failed to move %s out of the way, ignoring: %m",
                                                             full);
                         else
-                                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT,
-                                                    "Successfully moved %s out of the way.", full);
+                                log_debug("Successfully moved %s out of the way.", full);
 
                         continue;
                 }
@@ -651,8 +647,7 @@ static int vacuum_offline_user_journals(Server *s) {
 
                 r = journal_file_archive(f->file, NULL);
                 if (r < 0)
-                        log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT,
-                                                  "Failed to archive journal file '%s', ignoring: %m", full);
+                        log_debug_errno(r, "Failed to archive journal file '%s', ignoring: %m", full);
 
                 managed_journal_file_initiate_close(f, s->deferred_closes);
                 f = NULL;
@@ -666,7 +661,7 @@ void server_rotate(Server *s) {
         void *k;
         int r;
 
-        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Rotating...");
+        log_debug("Rotating...");
 
         /* First, rotate the system journal (either in its runtime flavour or in its runtime flavour) */
         (void) do_rotate(s, &s->runtime_journal, "runtime", false, 0);
@@ -743,7 +738,7 @@ static void do_vacuum(Server *s, JournalStorage *storage, bool verbose) {
 void server_vacuum(Server *s, bool verbose) {
         assert(s);
 
-        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Vacuuming...");
+        log_debug("Vacuuming...");
 
         s->oldest_file_usec = 0;
 
@@ -803,7 +798,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_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "%s: Allocation limit reached, rotating.", f->path);
+                log_debug("%s: Allocation limit reached, rotating.", f->path);
                 return true;
 
         case -EIO:             /* I/O error of some kind (mmap) */
@@ -924,7 +919,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n
         if (!f)
                 return;
 
-        log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT, "Retrying write.");
+        log_debug_errno(r, "Retrying write.");
         r = journal_file_append_entry(f->file, &ts, NULL, iovec, n, &s->seqnum, NULL, NULL);
         if (r < 0)
                 log_ratelimit_error_errno(r, FAILED_TO_WRITE_ENTRY_RATELIMIT,
@@ -1211,7 +1206,7 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
         if (!s->system_journal)
                 return 0;
 
-        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Flushing to %s...", s->system_storage.path);
+        log_debug("Flushing to %s...", s->system_storage.path);
 
         start = now(CLOCK_MONOTONIC);
 
@@ -1258,7 +1253,7 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
                         goto finish;
                 }
 
-                log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Retrying write.");
+                log_debug("Retrying write.");
                 r = journal_file_copy_entry(f, s->system_journal->file, o, f->current_offset);
                 if (r < 0) {
                         log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Can't write entry: %m");
@@ -1309,7 +1304,7 @@ static int server_relinquish_var(Server *s) {
         if (s->runtime_journal && !s->system_journal)
                 return 0;
 
-        log_ratelimit_debug(JOURNALD_LOG_RATELIMIT, "Relinquishing %s...", s->system_storage.path);
+        log_debug("Relinquishing %s...", s->system_storage.path);
 
         (void) system_journal_open(s, false, true);
 
index 4592bc7bba9c4560e8e914b27b9fc4f95ae63cc3..6394adfdfdf2291d30b214c92b99f4770b82ff5e 100644 (file)
@@ -50,8 +50,7 @@ static void forward_syslog_iovec(
         j = strjoina(s->runtime_directory, "/syslog");
         r = sockaddr_un_set_path(&sa.un, j);
         if (r < 0) {
-                log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT,
-                                          "Forwarding socket path %s too long for AF_UNIX, not forwarding: %m", j);
+                log_debug_errno(r, "Forwarding socket path %s too long for AF_UNIX, not forwarding: %m", j);
                 return;
         }
 
@@ -105,7 +104,7 @@ static void forward_syslog_iovec(
         }
 
         if (errno != ENOENT)
-                log_ratelimit_debug_errno(errno, JOURNALD_LOG_RATELIMIT, "Failed to forward syslog message: %m");
+                log_debug_errno(errno, "Failed to forward syslog message: %m");
 }
 
 static void forward_syslog_raw(Server *s, int priority, const char *buffer, size_t buffer_len, const struct ucred *ucred, const struct timeval *tv) {
index e7d4adca3e2f36981afa4bb62b873b282ebd585d..21ec5a785bf4b5f937eec613871ec054899f08d3 100644 (file)
@@ -50,5 +50,5 @@ void server_forward_wall(
 
         r = utmp_wall(l, "systemd-journald", NULL, NULL, NULL);
         if (r < 0)
-                log_ratelimit_debug_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to send wall message: %m");
+                log_debug_errno(r, "Failed to send wall message: %m");
 }