Blame SOURCES/0073-logging-test-log-level-at-first-step.patch

0c9110
From c362b6a9c4abb2f4185f5c88b90aecfebd6c67cb Mon Sep 17 00:00:00 2001
0c9110
From: Jakub Filak <jfilak@redhat.com>
0c9110
Date: Thu, 24 Jul 2014 13:34:50 +0200
0c9110
Subject: [LIBREPORT PATCH 73/93] logging: test log level at first step
0c9110
0c9110
Return from the logger immediately if message's log level is not
0c9110
sufficient to write it to the log.
0c9110
0c9110
This patch is a workaround for rhbz#1122690 where we try to log a
0c9110
'post'ed string which has 18MB of size. It is not worth to try to fix it
0c9110
properly. We do not log such a big amount of data in non-debug mode, we
0c9110
need to have the logging extremely fast and we can live with crashes in
0c9110
debug mode.
0c9110
0c9110
Resolves: #1142380
0c9110
0c9110
Signed-off-by: Jakub Filak <jfilak@redhat.com>
0c9110
---
0c9110
 src/lib/logging.c | 26 +++++++++++---------------
0c9110
 1 file changed, 11 insertions(+), 15 deletions(-)
0c9110
0c9110
diff --git a/src/lib/logging.c b/src/lib/logging.c
0c9110
index 259a634..4b9dd87 100644
0c9110
--- a/src/lib/logging.c
0c9110
+++ b/src/lib/logging.c
0c9110
@@ -66,7 +66,7 @@ static void log_handler(int level,
0c9110
                         int line,
0c9110
                         const char *func)
0c9110
 {
0c9110
-    if (!logmode)
0c9110
+    if (!logmode || !should_log(level))
0c9110
         return;
0c9110
 
0c9110
     /* This is ugly and costs +60 bytes compared to multiple
0c9110
@@ -122,29 +122,25 @@ static void log_handler(int level,
0c9110
     strcpy(&msg[used], msg_eol);
0c9110
 
0c9110
     if (flags & LOGMODE_STDIO) {
0c9110
-        if(should_log(level))
0c9110
-            full_write(STDERR_FILENO, msg, used + msgeol_len);
0c9110
+        full_write(STDERR_FILENO, msg, used + msgeol_len);
0c9110
     }
0c9110
     msg[used] = '\0'; /* remove msg_eol (usually "\n") */
0c9110
     if (flags & LOGMODE_SYSLOG) {
0c9110
-        if(should_log(level))
0c9110
-            syslog(level, "%s", msg + prefix_len);
0c9110
+        syslog(level, "%s", msg + prefix_len);
0c9110
     }
0c9110
 
0c9110
     if ((flags & LOGMODE_CUSTOM) && g_custom_logger) {
0c9110
-        if(should_log(level))
0c9110
-            g_custom_logger(msg + prefix_len);
0c9110
+        g_custom_logger(msg + prefix_len);
0c9110
     }
0c9110
 
0c9110
     if (flags & LOGMODE_JOURNAL) {
0c9110
-        if(should_log(level))
0c9110
-            sd_journal_send("MESSAGE=%s", msg + prefix_len,
0c9110
-                            "PRIORITY=%d", level,
0c9110
-                            "CODE_FILE=%s", file,
0c9110
-                            "CODE_LINE=%d", line,
0c9110
-                            "CODE_FUNC=%s", func,
0c9110
-                            "SYSLOG_FACILITY=1",
0c9110
-                            NULL);
0c9110
+        sd_journal_send("MESSAGE=%s", msg + prefix_len,
0c9110
+                        "PRIORITY=%d", level,
0c9110
+                        "CODE_FILE=%s", file,
0c9110
+                        "CODE_LINE=%d", line,
0c9110
+                        "CODE_FUNC=%s", func,
0c9110
+                        "SYSLOG_FACILITY=1",
0c9110
+                        NULL);
0c9110
     }
0c9110
 }
0c9110
 
0c9110
-- 
0c9110
1.8.3.1
0c9110