summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-04-20 10:43:21 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-04-20 13:43:36 +0200
commit3fe07e952515448fb04fd421376ca965947196ce (patch)
tree12046ed97f318a90b5422c400a380e945c9b6a60 /src/basic
parentlog: Add knob to disable kmsg ratelimiting (diff)
downloadsystemd-3fe07e952515448fb04fd421376ca965947196ce.tar.xz
systemd-3fe07e952515448fb04fd421376ca965947196ce.zip
log: Log when kmsg is being ratelimited
Let's avoid confusing developers and users when log messages suddenly stop getting logged to kmsg because of ratelimiting by logging an additional message if we start ratelimiting log messages to kmsg.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index d0fef3554f..4cd2d5a4ab 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -553,8 +553,12 @@ static int write_to_kmsg(
if (kmsg_fd < 0)
return 0;
- if (ratelimit_kmsg && !ratelimit_below(&ratelimit))
- return 0;
+ if (ratelimit_kmsg && !ratelimit_below(&ratelimit)) {
+ if (ratelimit_num_dropped(&ratelimit) > 1)
+ return 0;
+
+ buffer = "Too many messages being logged to kmsg, ignoring";
+ }
xsprintf(header_priority, "<%i>", level);
xsprintf(header_pid, "["PID_FMT"]: ", getpid_cached());