#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)
--- /dev/null
+/*
+ * 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;
+}
#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);
}
#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);
}