Fix logging in cynara-plugins 61/173761/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Fri, 23 Mar 2018 18:21:10 +0000 (19:21 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Fri, 23 Mar 2018 19:14:48 +0000 (20:14 +0100)
Cynara plugins include log.h in its interface, making log.h header
visible to external modules that implement plugins. Such change
was introduced to Cynara when log.h implemented only one kind of logger (journal).

Today, this file can alternatively compile to use syslog, journal or dlog,
depending on definitions passed from spec/cmake. This causes external modules
to rely on Cynara's internal macros, not defined in their cmake files.

This commit returns back "feature" of log.h to compile to syslog usage
as it was prior 0.14.15 release, in order to fix external module build breaks,
introduced by commit 632d8296266547f2291e03149e54fbc399bd9de8.

Ideally, this problem requires more changes - changing logging in dependent
modules not to use Cynara's loging definitions from log.h & removing log.h from API.

However, Since Cynara is an open source project and may be used outside Tizen, this change is
introduced first - modifying API should be done with careful consideration for external users.

Change-Id: I99c80ceb636fd9797b2419eb87b81171351b95f3

CMakeLists.txt
src/common/log/log.h

index 908eca79000143d183baa345466898a7cd8e9189..528b771d4fac3ddac3ba9ce3fd8b4808126db23a 100644 (file)
@@ -164,14 +164,14 @@ ENDIF (BUILD_WITH_SYSTEMD_DAEMON)
 
 IF (LOG_TYPE MATCHES "JOURNAL")
     ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD_JOURNAL")
-ELSEIF (LOG_TYPE MATCHES "SYSLOG")
-    ADD_DEFINITIONS("-DBUILD_WITH_SYSLOG")
 ELSEIF (LOG_TYPE MATCHES "DLOG")
     ADD_DEFINITIONS("-DBUILD_WITH_DLOG")
 ELSEIF (LOG_TYPE MATCHES "NONE")
     ADD_DEFINITIONS("-DCYNARA_NO_LOGS")
+ELSEIF (LOG_TYPE MATCHES "SYSLOG")
+    MESSAGE(STATUS "Using syslog - no additional definition needed")
 ELSE ()
-    MESSAGE(FATAL_ERROR "Unsupported logging mechanism")
+    MESSAGE(FATAL_ERROR "No logging option specified")
 ENDIF ()
 
 IF (BUILD_SERVICE)
index f9e7dc4e5e4fdae78236d1bd637913f28eae65e0..70871c76f170f42caadb3de52b651c92770d9b93 100644 (file)
 #include <sstream>
 #ifdef BUILD_WITH_SYSTEMD_JOURNAL
 #include <systemd/sd-journal.h>
-#elif defined(BUILD_WITH_SYSLOG)
-#include <syslog.h>
 #elif defined(BUILD_WITH_DLOG)
 #include "DlogLog.h"
+#else
+#include <syslog.h>
 #endif
 #endif // CYNARA_NO_LOGS
 
@@ -49,7 +49,7 @@ namespace {
         sd_journal_print(level, std::forward<Args>(args)...);
 #elif defined(BUILD_WITH_DLOG)
         cynara_dlog_print(level, std::forward<Args>(args)...);
-#elif defined(BUILD_WITH_SYSLOG)
+#else
         syslog(level, std::forward<Args>(args)...);
 #endif
     }