Fixed build error that appeared after Log Tag refactor 81/65281/1
authorAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Fri, 8 Apr 2016 08:02:25 +0000 (11:02 +0300)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Fri, 8 Apr 2016 08:02:25 +0000 (11:02 +0300)
Change-Id: Ife899ebdab67dc324cdd48e1c906491065f0f502
Signed-off-by: Aleksandr Sapozhnik <a.sapozhnik@samsung.com>
lib-apps-common/inc/Utils/Logger.h
lib-apps-common/src/Utils/Logger.cpp [new file with mode: 0644]
main-app/src/main.cpp
widget/src/main.cpp

index 059bb3f691b7bd5f41f465ae7702209b6f340343..8ddc08703f5bf9da9c78dd59d67a5e6bf558bd3c 100644 (file)
 #ifndef UTILS_LOGGER_H
 #define UTILS_LOGGER_H
 
-extern const char *appsCommonLogTag;
-#define SET_LOG_TAG(tag) const char *appsCommonLogTag = tag
-
+#include <tizen.h>
 #include <dlog.h>
 
+namespace Utils
+{
+       /**
+        * @brief Sets the log tag
+        * @param[in]   logTag The log tag
+        */
+       EXPORT_API void setLogTag(const char *logTag);
+
+       /**
+        * @brief Returns the log tag
+        * @return The log tag
+        */
+       EXPORT_API const char *getLogTag();
+}
+
 #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
 
 #include "Utils/Tracer.h"
-#define TRACE ::Utils::Tracer tracer(appsCommonLogTag, __MODULE__, __func__, __LINE__)
+#define TRACE ::Utils::Tracer tracer(::Utils::getLogTag(), __MODULE__, __func__, __LINE__)
 
-#define DLOG(prio, fmt, arg...) dlog_print(prio, appsCommonLogTag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg)
+#define DLOG(prio, fmt, arg...) dlog_print(prio, ::Utils::getLogTag(), "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg)
 #define DBG(fmt, arg...) DLOG(DLOG_DEBUG, fmt, ##arg)
 #define ERR(fmt, arg...) DLOG(DLOG_ERROR, fmt, ##arg)
 
diff --git a/lib-apps-common/src/Utils/Logger.cpp b/lib-apps-common/src/Utils/Logger.cpp
new file mode 100644 (file)
index 0000000..1bfb8ef
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Utils/Logger.h"
+#include <stdio.h>
+
+static char appsCommonLogTag[64] = "DefaultLogTag";
+
+void Utils::setLogTag(const char *logTag)
+{
+       snprintf(appsCommonLogTag, sizeof(appsCommonLogTag), "%s", logTag);
+}
+
+const char *Utils::getLogTag()
+{
+       return appsCommonLogTag;
+}
index 9f15ebbd5ed923264151863c768240d4dfba94be..e4b365f4f18804a694fc7b77374127dcc938ed04 100644 (file)
@@ -18,9 +18,8 @@
 #include "MainApp.h"
 #include "Utils/Logger.h"
 
-SET_LOG_TAG("contacts");
-
 int main(int argc, char *argv[])
 {
+       Utils::setLogTag("contacts");
        return MainApp().run(argc, argv);
 }
index d80fa164be3746e14f0cf08d46579d9f991496ad..22938cc5772977d46607dea9d902b9ce8a3c7d76 100644 (file)
@@ -18,9 +18,8 @@
 #include "WidgetApp.h"
 #include "Utils/Logger.h"
 
-SET_LOG_TAG("contacts-widget");
-
 int main(int argc, char *argv[])
 {
+       Utils::setLogTag("contacts-widget");
        return WidgetApp().run(argc, argv);
 }