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

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