Add conditional logs building 36/24536/2
authorAdam Malinowski <a.malinowsk2@partner.samsung.com>
Tue, 15 Jul 2014 12:16:20 +0000 (14:16 +0200)
committerAdam Malinowski <a.malinowsk2@partner.samsung.com>
Wed, 16 Jul 2014 07:21:15 +0000 (09:21 +0200)
This feature is needed for correct building tests when tested
units use logging mechanism. Tests should not depend on logger.

Change-Id: I110f5f0238726d1110388eaefc028c90747aa747

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

index b697195..df023ba 100644 (file)
 #ifndef SRC_COMMON_LOG_BACKTRACE_H_
 #define SRC_COMMON_LOG_BACKTRACE_H_
 
+#ifndef CYNARA_NO_LOGS
 #define UNW_LOCAL_ONLY
 #include <libunwind.h>
+#endif
 #include <string>
 
 namespace Cynara {
 
 class Backtrace {
 public:
-#ifdef BUILD_TYPE_DEBUG
+#if defined(BUILD_TYPE_DEBUG) && !defined(CYNARA_NO_LOGS)
     static const std::string getBacktrace(void);
 #else
     static const std::string getBacktrace(void) {
@@ -51,7 +53,9 @@ private:
     void operator=(Backtrace const &) = delete;
 
     const std::string buildBacktrace(void);
+#ifndef CYNARA_NO_LOGS
     void getSourceInfo(unw_word_t proc_address);
+#endif
 
 private:
     const char *m_fileName;
index 6f1eca4..0ed2c3e 100644 (file)
 #ifndef CYNARA_COMMON_LOG_H
 #define CYNARA_COMMON_LOG_H
 
+#ifndef CYNARA_NO_LOGS
 #include <systemd/sd-journal.h>
+#endif
 
 extern int __log_level;
 
-#define __LOG(LEVEL, ...) \
-    do { \
-        if(LEVEL <= __log_level) \
-            sd_journal_print(LEVEL, __VA_ARGS__); \
-    } while (0)
+#ifndef CYNARA_NO_LOGS
+    #define __LOG(LEVEL, ...) \
+        do { \
+            if(LEVEL <= __log_level) \
+                sd_journal_print(LEVEL, __VA_ARGS__); \
+        } while (0)
+#else
+    #define __LOG(LEVEL, ...)
+#endif
 
 #define LEGM(...)  __LOG(LOG_EMERG, __VA_ARGS__)   /* system is unusable */
 #define LOGA(...)  __LOG(LOG_ALERT, __VA_ARGS__)   /* action must be taken immediately */
index 0b6f913..52117a5 100644 (file)
@@ -37,6 +37,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE    "-g -std=c++0x -O2")
 ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
+ADD_DEFINITIONS("-DCYNARA_NO_LOGS")             # Disable building logs
 
 MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")