Remove debug logs in release build. 83/44783/2
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 27 Jul 2015 14:45:35 +0000 (16:45 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Tue, 28 Jul 2015 10:25:23 +0000 (12:25 +0200)
[Bug]           Remove debug logs in release build.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build release/debug, run server.

Change-Id: Id34991a45e0fbee8edddfea10b64f69809141af3

common/utils/execute.cpp
common/utils/fs.cpp
libs/dbus/connection.cpp
libs/ipc/epoll/event-poll.cpp
libs/ipc/internals/processor.cpp
libs/logger/logger-scope.hpp
libs/logger/logger.hpp
server/main.cpp
tests/unit_tests/log/ut-logger.cpp
wrapper/wrapper-compatibility.cpp
zone-daemon/main.cpp

index d030177..4b6d59d 100644 (file)
@@ -35,7 +35,7 @@ namespace utils {
 
 namespace {
 
-std::ostream& operator<< (std::ostream& out, const char* const* argv)
+__attribute__((unused)) std::ostream& operator<< (std::ostream& out, const char* const* argv)
 {
     if (*argv) {
         argv++; //skip
index a093c9e..a7a979a 100644 (file)
@@ -201,10 +201,13 @@ bool isMountPoint(const std::string& path, bool& result)
 {
     std::string parentPath = dirName(path);
     bool newResult;
-    bool ret = hasSameMountPoint(path, parentPath, newResult);
+    if (!hasSameMountPoint(path, parentPath, newResult)) {
+        LOGE("Failed to check the files' mount points");
+        return false;
+    }
 
     result = !newResult;
-    return ret;
+    return true;
 }
 
 bool hasSameMountPoint(const std::string& path1, const std::string& path2, bool& result)
index ee4cea9..5851631 100644 (file)
@@ -181,7 +181,7 @@ void DbusConnection::setName(const std::string& name,
                                            &deleteCallbackWrapper<NameCallbacks>);
 }
 
-void DbusConnection::onNameAcquired(GDBusConnection*, const gchar* name, gpointer userData)
+void DbusConnection::onNameAcquired(GDBusConnection*, __attribute__((unused)) const gchar* name, gpointer userData)
 {
     LOGD("Name acquired " << name);
     const NameCallbacks& callbacks = getCallbackFromPointer<NameCallbacks>(userData);
@@ -190,7 +190,7 @@ void DbusConnection::onNameAcquired(GDBusConnection*, const gchar* name, gpointe
     }
 }
 
-void DbusConnection::onNameLost(GDBusConnection*, const gchar* name, gpointer userData)
+void DbusConnection::onNameLost(GDBusConnection*, __attribute__((unused)) const gchar* name, gpointer userData)
 {
     LOGD("Name lost " << name);
     const NameCallbacks& callbacks = getCallbackFromPointer<NameCallbacks>(userData);
index b6c4902..650e121 100644 (file)
@@ -51,7 +51,7 @@ EventPoll::~EventPoll()
 {
     if (!mCallbacks.empty()) {
         LOGW("Not removed callbacks: " << mCallbacks.size());
-        for (const auto& item : mCallbacks) {
+        for (__attribute__((unused)) const auto& item : mCallbacks) {
             LOGT("Not removed fd: " << item.first);
         }
         assert(0 && "Not removed callbacks left");
index 8f81b24..a8c671e 100644 (file)
@@ -389,8 +389,8 @@ bool Processor::onReturnValue(Peers::iterator& peerIt,
 }
 
 bool Processor::onRemoteSignal(Peers::iterator& peerIt,
-                               const MethodID methodID,
-                               const MessageID messageID,
+                               __attribute__((unused)) const MethodID methodID,
+                               __attribute__((unused)) const MessageID messageID,
                                std::shared_ptr<SignalHandlers> signalCallbacks)
 {
     LOGS(mLogPrefix + "Processor onRemoteSignal; methodID: " << methodID << " messageID: " << messageID);
index 41a99bf..1462272 100644 (file)
@@ -74,8 +74,12 @@ private:
  * @brief Automatically create LoggerScope object which logs at the construction and destruction
  * @ingroup libLogger
  */
+#if !defined(NDEBUG)
 #define LOGS(MSG)   logger::LoggerScope logScopeObj(__FILE__, __LINE__, __func__,    \
                                                     logger::SStreamWrapper() << MSG, \
                                                     PROJECT_SOURCE_DIR)
+#else
+#define LOGS(MSG) do {} while (0)
+#endif
 
 #endif // COMMON_LOGGER_LOGGER_SCOPE_HPP
index e27d3dd..bedddb0 100644 (file)
@@ -117,6 +117,7 @@ public:
 /// Logging information
 #define LOGI(MESSAGE) LOG(INFO, MESSAGE)
 
+#if !defined(NDEBUG)
 /// Logging debug information
 #define LOGD(MESSAGE) LOG(DEBUG, MESSAGE)
 
@@ -125,6 +126,12 @@ public:
 
 /// Logging tracing information
 #define LOGT(MESSAGE) LOG(TRACE, MESSAGE)
+#else
+#define LOGD(MESSAGE) do {} while (0)
+#define LOGH(MESSAGE) do {} while (0)
+#define LOGT(MESSAGE) do {} while (0)
+#endif
 
 #endif // COMMON_LOGGER_LOGGER_HPP
-/*@}*/
\ No newline at end of file
+
+/*@}*/
index 707eb50..e9440cb 100644 (file)
  * @brief   Main file for the Vasum Daemon
  */
 
-// Always log to console in DEBUG mode
-#if !defined(LOG_TO_CONSOLE) && !defined(NDEBUG)
-#define LOG_TO_CONSOLE
-#endif
-
 #include "config.hpp"
 
 #include "exception.hpp"
@@ -109,7 +104,7 @@ int main(int argc, char* argv[])
         }
 
         Logger::setLogLevel(vm["log-level"].as<std::string>());
-#ifdef LOG_TO_CONSOLE
+#if !defined(NDEBUG)
         Logger::setLogBackend(new StderrBackend());
 #elif HAVE_SYSTEMD
         Logger::setLogBackend(new SystemdJournalBackend());
index 36f52e3..9201f8f 100644 (file)
@@ -176,6 +176,7 @@ BOOST_AUTO_TEST_CASE(LogsLevelInfo)
     BOOST_CHECK(tf.logContains("[TRACE]") == false);
 }
 
+#if !defined(NDEBUG)
 BOOST_AUTO_TEST_CASE(LogsLevelDebug)
 {
     TestLog tf(LogLevel::DEBUG);
@@ -199,6 +200,7 @@ BOOST_AUTO_TEST_CASE(LogsLevelTrace)
     BOOST_CHECK(tf.logContains("[DEBUG]") == true);
     BOOST_CHECK(tf.logContains("[TRACE]") == true);
 }
+#endif
 
 BOOST_AUTO_TEST_CASE(LoggerScope)
 {
index 6c3dfa9..634c187 100644 (file)
@@ -278,7 +278,9 @@ API int sock_send_fd(int fd, int sendfd, void *data, size_t size) {
     return sendmsg(fd, &msg, MSG_NOSIGNAL);
 }
 // vasum_log
-API void vasum_log(int type, const char *tag, const char *fmt, ...) {
+API void vasum_log(__attribute__((unused)) int type,
+                   __attribute__((unused)) const char *tag,
+                   const char *fmt, ...) {
     va_list arg_ptr;
     char buf[255];
     LOGS("type=" << type << " tag=" << tag);
index 0cfe21f..58fad9b 100644 (file)
  * @brief   Main file for the Vasum Daemon
  */
 
-// Always log to console in DEBUG mode
-#if !defined(LOG_TO_CONSOLE) && !defined(NDEBUG)
-#define LOG_TO_CONSOLE
-#endif
-
 #include "config.hpp"
 
 #include "exception.hpp"
@@ -99,7 +94,7 @@ int main(int argc, char* argv[])
         }
 
         Logger::setLogLevel(vm["log-level"].as<std::string>());
-#ifdef LOG_TO_CONSOLE
+#if !defined(NDEBUG)
         Logger::setLogBackend(new StderrBackend());
 #elif HAVE_SYSTEMD
         Logger::setLogBackend(new SystemdJournalBackend());