diff mbox series

syslog: suppress message not belonging to log

Message ID 20201118171559.106405-1-sbabic@denx.de
State Accepted
Headers show
Series syslog: suppress message not belonging to log | expand

Commit Message

Stefano Babic Nov. 18, 2020, 5:15 p.m. UTC
Some messages sent to the notifier are not for logging, but they are for
the progress interface or they must reach a process. Currently, such as
messages are not recognized and a FATAL_UNKNOWN mesagge is sent to the
syslog server. This simply ignores messages that do not need to be
looged.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Christian Storm <christian.storm@siemens.com>
---
 core/syslog.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/core/syslog.c b/core/syslog.c
index f69c337..a7aa6af 100644
--- a/core/syslog.c
+++ b/core/syslog.c
@@ -20,8 +20,6 @@  void syslog_notifier(RECOVERY_STATUS status, int error, int level, const char *m
 {
    const char* statusMsg;
 
-   openlog("swupdate", 0, LOG_USER);
-
    switch(status) {
       case IDLE: statusMsg = "IDLE"; break;
       case DOWNLOAD: statusMsg = "DOWNLOAD"; break;
@@ -30,9 +28,15 @@  void syslog_notifier(RECOVERY_STATUS status, int error, int level, const char *m
       case SUCCESS: statusMsg = "SUCCESS"; break;
       case FAILURE: statusMsg = "FAILURE"; break;
       case DONE: statusMsg = "DONE"; break;
-      default: statusMsg = "UNKNOWN"; break;
+      /*
+       * Unknown messages are maybe for other subsystems
+       * and not to the logger, so silently ignore them
+       */
+      default: return;
    }
 
+   openlog("swupdate", 0, LOG_USER);
+
    int logprio = LOG_INFO;
    switch (level) {
       case ERRORLEVEL: logprio = LOG_ERR; break;