#define LOG_TAG NULL
#endif
-#define LOG_ON() _get_logging_on()
-
#ifndef __MODULE__
#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
+
/*
* log priority values, in ascending priority order.
*/
DLOG_ERROR,
DLOG_FATAL,
DLOG_SILENT,
+ DLOG_PRIO_MAX /* Keep this always at the end. */
} log_priority;
typedef enum {
#define CONDITION(cond) (__builtin_expect((cond) != 0, 0))
-// ---------------------------------------------------------------------
-/**
- * Secure Log Macro.
- */
-
-#define _SECURE_LOG 1
+#define _SECURE_LOG /* Temporary default added, This define code will be removed */
-#ifndef SECLOG
-#if _SECURE_LOG
-#define SECLOG(...) (0)
+// Macro inner work---------------------------------------------------------------
+#undef _SECURE_
+#ifndef _SECURE_LOG
+#define _SECURE_ (0)
#else
-#define SECLOG(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
-
+#define _SECURE_ (1)
+#endif
+#undef LOG_
+#define LOG_(id, prio, tag, fmt, arg...) \
+ ( __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg))
+#undef SECURE_LOG_
+#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
+ (_SECURE_ ? ( __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg)) : (0))
// ---------------------------------------------------------------------
/**
- * Simplified macro to send a verbose log message using the current LOG_TAG.
- */
-#ifndef LOGV
-#if LOG_NDEBUG
-#define LOGV(...) (0)
-#else
-#define LOGV(format, arg...) \
- (LOG_ON() ? (LOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
-/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * For Secure Log.
+ * Normally we strip Secure log from release builds.
+ * Please use this macros.
*/
-#ifndef LOGV_IF
-#if LOG_NDEBUG
-#define LOGV_IF(cond, format, arg...) (0)
-#else
-#define LOGV_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
/**
- * Simplified macro to send a debug log message using the current LOG_TAG.
- */
-#ifndef LOGD
-#define LOGD(format, arg...) \
- (LOG_ON() ? (LOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * For Application and etc.
+ * Simplified macro to send a main log message using the current LOG_TAG.
+ * Example:
+ * SECURE_LOGD("app debug %d", num);
+ * SECURE_LOGE("app error %d", num);
*/
-#ifndef LOGD_IF
-#define LOGD_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
+#define SECURE_LOGD(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SECURE_LOGI(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SECURE_LOGW(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SECURE_LOGE(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send an info log message using the current LOG_TAG.
+ * For Framework and system etc.
+ * Simplified macro to send a system log message using the current LOG_TAG.
+ * Example:
+ * SECURE_SLOGD("system debug %d", num);
+ * SECURE_SLOGE("system error %d", num);
*/
-#ifndef LOGI
-#define LOGI(format, arg...) \
- (LOG_ON() ? (LOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define SECURE_SLOGD(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SECURE_SLOGI(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SECURE_SLOGW(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SECURE_SLOGE(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * For Modem and radio etc.
+ * Simplified macro to send a radio log message using the current LOG_TAG.
+ * Example:
+ * SECURE_RLOGD("radio debug %d", num);
+ * SECURE_RLOGE("radio error %d", num);
*/
-#ifndef LOGI_IF
-#define LOGI_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
+#define SECURE_RLOGD(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SECURE_RLOGI(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SECURE_RLOGW(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SECURE_RLOGE(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send a warning log message using the current LOG_TAG.
+ * For Tizen OSP Application macro.
*/
-#ifndef LOGW
-#define LOGW(format, arg...) \
- (LOG_ON() ? (LOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define SECURE_ALOGD(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SECURE_ALOGI(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SECURE_ALOGW(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SECURE_ALOGE(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * If you want use redefined macro.
+ * You can use this macro.
+ * This macro need priority and tag arguments.
*/
-#ifndef LOGW_IF
-#define LOGW_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define SECURE_LOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
+#define SECURE_SLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
+#define SECURE_RLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
+#define SECURE_ALOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
+#define SECLOG(format, arg...) do { } while (0)
/**
- * Simplified macro to send an error log message using the current LOG_TAG.
+ * For Application and etc.
+ * Simplified macro to send a main log message using the current LOG_TAG.
+ * Example:
+ * LOGD("app debug %d", num);
+ * LOGE("app error %d", num);
*/
-#ifndef LOGE
-#define LOGE(format, arg...) \
- (LOG_ON() ? (LOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define LOGD(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define LOGI(format, arg...) LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
+#define LOGW(format, arg...) LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
+#define LOGE(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * For Framework and system etc.
+ * Simplified macro to send a system log message using the current LOG_TAG.
+ * Example:
+ * SLOGD("system debug %d", num);
+ * SLOGE("system error %d", num);
*/
-#ifndef LOGE_IF
-#define LOGE_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define SLOGD(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SLOGI(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SLOGW(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SLOGE(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send an error log message using the current LOG_TAG.
+ * For Modem and radio etc.
+ * Simplified macro to send a radio log message using the current LOG_TAG.
+ * Example:
+ * RLOGD("radio debug %d", num);
+ * RLOGE("radio error %d", num);
*/
-#ifndef LOGF
-#define LOGF(format, arg...) \
- (LOG_ON() ? (LOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define RLOGD(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define RLOGI(format, arg...) LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
+#define RLOGW(format, arg...) LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
+#define RLOGE(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
+ * For Tizen OSP Application macro.
*/
-#ifndef LOGF_IF
-#define LOGF_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (LOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+#define ALOGD(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define ALOGI(format, arg...) LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
+#define ALOGW(format, arg...) LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
+#define ALOGE(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
-// ---------------------------------------------------------------------
-/**
- * Simplified radio macro to send a verbose log message using the current LOG_TAG.
- */
-#ifndef RLOGV
-#if LOG_NDEBUG
-#define RLOGV(...) (0)
-#else
-#define RLOGV(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
+ * Conditional Macro.
+ * Don't use this macro. It's just compatibility.
*/
-#ifndef RLOGV_IF
-#if LOG_NDEBUG
-#define RLOGV_IF(cond, format, arg...) (0)
-#else
-#define RLOGV_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
-
-/**
- * Simplified radio macro to send a debug log message using the current LOG_TAG.
- */
-#ifndef RLOGD
-#define RLOGD(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef RLOGD_IF
+#define LOGD_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGD(format, ##arg)) : (0))
+#define LOGI_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGI(format, ##arg)) : (0))
+#define LOGW_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGW(format, ##arg)) : (0))
+#define LOGE_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGE(format, ##arg)) : (0))
+#define SLOGD_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGD(format, ##arg)) : (0))
+#define SLOGI_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGI(format, ##arg)) : (0))
+#define SLOGW_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGW(format, ##arg)) : (0))
+#define SLOGE_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGE(format, ##arg)) : (0))
#define RLOGD_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified radio macro to send an info log message using the current LOG_TAG.
- */
-#ifndef RLOGI
-#define RLOGI(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef RLOGI_IF
+ ((CONDITION(cond)) ? (RLOGD(format, ##arg)) : (0))
#define RLOGI_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified radio macro to send a warning log message using the current LOG_TAG.
- */
-#ifndef RLOGW
-#define RLOGW(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef RLOGW_IF
+ ((CONDITION(cond)) ? (RLOGI(format, ##arg)) : (0))
#define RLOGW_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified radio macro to send an error log message using the current LOG_TAG.
- */
-#ifndef RLOGE
-#define RLOGE(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef RLOGE_IF
+ ((CONDITION(cond)) ? (RLOGW(format, ##arg)) : (0))
#define RLOGE_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified radio macro to send an error log message using the current LOG_TAG.
- */
-#ifndef RLOGF
-#define RLOGF(format, arg...) \
- (LOG_ON() ? (RLOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
+ ((CONDITION(cond)) ? (RLOGE(format, ##arg)) : (0))
+
/**
- * Simplified radio macro to send a conditional verbose log message using the current LOG_TAG.
+ * Basic log message macro that allows you to specify a priority and a tag
+ * if you want to use this macro directly, you must add this messages for unity of messages.
+ * (LOG(prio, tag, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg))
+ *
+ * Example:
+ * #define MYMACRO(prio, tag, format, arg...) \
+ * LOG(prio, tag, format, ##arg)
+ *
+ * MYMACRO(LOG_DEBUG, MYTAG, "test mymacro %d", num);
+ *
*/
-#ifndef RLOGF_IF
-#define RLOGF_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (RLOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
+#ifndef LOG
+#define LOG(priority, tag, format, arg...) LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
#endif
+#define SLOG(priority, tag, format, arg...) LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
+#define RLOG(priority, tag, format, arg...) LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
+#define ALOG(priority, tag, format, arg...) LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
// ---------------------------------------------------------------------
-/**
- * Simplified system macro to send a verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGV
+// Don't use below macro no more!! It will be removed -- Verbose and Fatal priority macro will be removed --
+#define COMPATIBILITY_ON
+
+#ifdef COMPATIBILITY_ON
+#define LOG_ON() _get_logging_on()
#if LOG_NDEBUG
-#define SLOGV(...) (0)
+#define LOGV(format, arg...) (0)
#else
-#define SLOGV(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
+#define LOGV(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
#endif
-#endif
-/**
- * Simplified macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGV_IF
+#define LOGF(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
#if LOG_NDEBUG
-#define SLOGV_IF(cond, format, arg...) (0)
+#define SLOGV(format, arg...) (0)
#else
-#define SLOGV_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_VERBOSE, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-#endif
-
-/**
- * Simplified system macro to send a debug log message using the current LOG_TAG.
- */
-#ifndef SLOGD
-#define SLOGD(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified system macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGD_IF
-#define SLOGD_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_DEBUG, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified system macro to send an info log message using the current LOG_TAG.
- */
-#ifndef SLOGI
-#define SLOGI(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified system macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGI_IF
-#define SLOGI_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_INFO, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified system macro to send a warning log message using the current LOG_TAG.
- */
-#ifndef SLOGW
-#define SLOGW(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified system macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGW_IF
-#define SLOGW_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-/**
- * Simplified system macro to send an error log message using the current LOG_TAG.
- */
-#ifndef SLOGE
-#define SLOGE(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified system macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGE_IF
-#define SLOGE_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_ERROR, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-/**
- * Simplified system macro to send an error log message using the current LOG_TAG.
- */
-#ifndef SLOGF
-#define SLOGF(format, arg...) \
- (LOG_ON() ? (SLOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
+#define SLOGV(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
#endif
-/**
- * Simplified system macro to send a conditional verbose log message using the current LOG_TAG.
- */
-#ifndef SLOGF_IF
-#define SLOGF_IF(cond, format, arg...) \
- (((CONDITION(cond)) && (LOG_ON())) ? \
- (SLOG(LOG_FATAL, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
-#endif
-
-// ---------------------------------------------------------------------
-
-/**
- * Simplified macro to send a verbose log message using the current LOG_TAG.
- */
-#ifndef ALOGV
+#define SLOGF(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
#if LOG_NDEBUG
-#define ALOGV(...) (0)
+#define RLOGV(format, arg...) (0)
#else
-#define ALOGV(...) (ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
-#endif
-#endif
-/**
- * Simplified macro to send a debug log message using the current LOG_TAG.
- */
-#ifndef ALOGD
-#define ALOGD(...) (ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
-#endif
-/**
- * Simplified macro to send an info log message using the current LOG_TAG.
- */
-#ifndef ALOGI
-#define ALOGI(...) (ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
-#endif
-/**
- * Simplified macro to send a warning log message using the current LOG_TAG.
- */
-#ifndef ALOGW
-#define ALOGW(...) (ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define RLOGV(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
#endif
-/**
- * Simplified macro to send an error log message using the current LOG_TAG.
- */
-#ifndef ALOGE
-#define ALOGE(...) (ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
-#endif
-
-
-// ---------------------------------------------------------------------
-/**
- * Basic log message macro that allows you to specify a priority and a tag
- *
- * Example:
- * LOG(DLOG_WARN, NULL, "Failed with error %d", errno);
- *
- * The second argument may be NULL or "" to indicate the "global" tag.
- *
- * Future work : we want to put filename and line number automatically only when debug build mode
- */
-#ifndef LOG
-#define LOG(priority, tag, ...) \
- print_log(D##priority, tag, __VA_ARGS__)
+#define RLOGF(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
+#if LOG_NDEBUG
+#define ALOGV(format, arg...) (0)
+#else
+#define ALOGV(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
#endif
-
-/**
- * Log macro that allows you to pass in a varargs ("args" is a va_list).
- */
-#ifndef LOG_VA
+#define ALOGF(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
+#define LOGV_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGD(format, ##arg)) : (0))
+#define LOGF_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (LOGE(format, ##arg)) : (0))
+#define SLOGV_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGD(format, ##arg)) : (0))
+#define SLOGF_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (SLOGE(format, ##arg)) : (0))
+#define RLOGV_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (RLOGD(format, ##arg)) : (0))
+#define RLOGF_IF(cond, format, arg...) \
+ ((CONDITION(cond)) ? (RLOGE(format, ##arg)) : (0))
#define LOG_VA(priority, tag, fmt, args) \
vprint_log(D##priority, tag, fmt, args)
-#endif
-
-#ifndef ALOG
-#define ALOG(priority, tag, ...) \
- print_apps_log(D##priority, tag, __VA_ARGS__)
-#endif
-/**
- * Log macro that allows you to pass in a varargs ("args" is a va_list).
- */
-#ifndef ALOG_VA
#define ALOG_VA(priority, tag, fmt, args) \
vprint_apps_log(D##priority, tag, fmt, args)
-#endif
-
-/**
- * Basic radio log macro that allows you to specify a priority and a tag.
- */
-#ifndef RLOG
-#define RLOG(priority, tag, ...) \
- print_radio_log(D##priority, tag, __VA_ARGS__)
-#endif
-/**
- * Radio log macro that allows you to pass in a varargs ("args" is a va_list).
- */
-#ifndef RLOG_VA
#define RLOG_VA(priority, tag, fmt, args) \
vprint_radio_log(D##priority, tag, fmt, args)
-#endif
-
-/**
- * Basic system log macro that allows you to specify a priority and a tag.
- */
-#ifndef SLOG
-#define SLOG(priority, tag, ...) \
- print_system_log(D##priority, tag, __VA_ARGS__)
-#endif
-
-/**
- * System log macro that allows you to pass in a varargs ("args" is a va_list).
- */
-#ifndef SLOG_VA
#define SLOG_VA(priority, tag, fmt, args) \
vprint_system_log(D##priority, tag, fmt, args)
-#endif
-
-
-/*
- * ===========================================================================
- *
- * The stuff in the rest of this file should not be used directly.
- */
-
#define print_apps_log(prio, tag, fmt...) \
__dlog_print(LOG_ID_APPS, prio, tag, fmt)
-
#define vprint_apps_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_APPS, prio, tag, fmt)
-
#define print_log(prio, tag, fmt...) \
__dlog_print(LOG_ID_MAIN, prio, tag, fmt)
-
#define vprint_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_MAIN, prio, tag, fmt)
-
#define print_radio_log(prio, tag, fmt...)\
__dlog_print(LOG_ID_RADIO, prio, tag, fmt)
-
#define vprint_radio_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_RADIO, prio, tag, fmt)
-
#define print_system_log(prio, tag, fmt...)\
__dlog_print(LOG_ID_SYSTEM, prio, tag, fmt)
-
#define vprint_system_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_SYSTEM, prio, tag, fmt)
-
+#endif
+// Don't use above macro no more!! It will be removed -Verbose, Warning and Fatal priority macro.
+// ---------------------------------------------------------------------
+/*
+ * The stuff in the rest of this file should not be used directly.
+ */
/**
* @brief send log. must specify log_id ,priority, tag and format string.
* @pre none
*/
int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap);
int _get_logging_on(void);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-
/** @} */
/** @} */
-
#endif /* _DLOG_H_*/
-
-/*
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-
* DLOG
* Copyright (c) 2005-2008, The Android Open Source Project
* Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <dlog.h>
-#ifdef SD_JOURNAL_SUPPORT
+#ifdef HAVE_SYSTEMD_JOURNAL
+#define SD_JOURNAL_SUPPRESS_LOCATION 1
#include <syslog.h>
#include <systemd/sd-journal.h>
#endif
#define LOG_SYSTEM "log_system"
#define LOG_APPS "log_apps"
-static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 };
-
-static int g_logging_on = 1;
-static int g_dlog_level_init = 0;
-static int g_dlog_level = DLOG_SILENT;
+#define VALUE_MAX 2
+#define PLATFORMLOG_CONF "/tmp/.platformlog.conf"
+#define PLATFORMLOG_ORG_CONF "/opt/etc/platformlog.conf"
-static int __dlog_init(log_id_t, log_priority, const char *tag, const char *msg);
-static int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg) = __dlog_init;
+static int platformlog = 0;
+static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 };
+static int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg) = NULL;
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
+
static int __write_to_log_null(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
{
return -1;
return ret;
}
+
static char dlog_pri_to_char (log_priority pri)
{
- switch (pri) {
- case DLOG_VERBOSE: return 'V';
- case DLOG_DEBUG: return 'D';
- case DLOG_INFO: return 'I';
- case DLOG_WARN: return 'W';
- case DLOG_ERROR: return 'E';
- case DLOG_FATAL: return 'F';
- case DLOG_SILENT: return 'S';
-
- case DLOG_DEFAULT:
- case DLOG_UNKNOWN:
- default:
- return '?';
- }
+ static const char pri_table[DLOG_PRIO_MAX] = {
+ [DLOG_VERBOSE] = 'V',
+ [DLOG_DEBUG] = 'D',
+ [DLOG_INFO] = 'I',
+ [DLOG_WARN] = 'W',
+ [DLOG_ERROR] = 'E',
+ [DLOG_FATAL] = 'F',
+ [DLOG_SILENT] = 'S',
+ };
+
+ if (pri < 0 || DLOG_PRIO_MAX <= pri || !pri_table[pri])
+ return '?';
+ return pri_table[pri];
}
-#ifdef SD_JOURNAL_SUPPORT
-static int dlog_pri_to_journal_pri(log_priority prio)
+
+#ifdef HAVE_SYSTEMD_JOURNAL
+static inline int dlog_pri_to_journal_pri(log_priority prio)
{
- int journal_prio = LOG_DEBUG;
-
- switch(prio) {
- case DLOG_UNKNOWN:
- case DLOG_DEFAULT:
- case DLOG_VERBOSE:
- journal_prio = LOG_DEBUG;
- break;
- case DLOG_DEBUG:
- journal_prio = LOG_DEBUG;
- break;
- case DLOG_INFO:
- journal_prio = LOG_INFO;
- break;
- case DLOG_WARN:
- journal_prio = LOG_WARNING;
- break;
- case DLOG_ERROR:
- journal_prio = LOG_ERR;
- break;
- case DLOG_FATAL:
- journal_prio = LOG_CRIT;
- break;
- case DLOG_SILENT:
- default:
- journal_prio = -1;
- break;
- }
- return journal_prio;
+ static int pri_table[DLOG_PRIO_MAX] = {
+ [DLOG_UNKNOWN] = LOG_DEBUG,
+ [DLOG_DEFAULT] = LOG_DEBUG,
+ [DLOG_VERBOSE] = LOG_DEBUG,
+ [DLOG_DEBUG] = LOG_DEBUG,
+ [DLOG_INFO] = LOG_INFO,
+ [DLOG_WARN] = LOG_WARNING,
+ [DLOG_ERROR] = LOG_ERR,
+ [DLOG_FATAL] = LOG_CRIT,
+ [DLOG_SILENT] = -1,
+ };
+
+ if (prio < 0 || prio >= DLOG_PRIO_MAX)
+ return -EINVAL;
+
+ return pri_table[prio];
}
-static int __write_to_log_sd_journal_print(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
+
+static inline const char* dlog_id_to_string(log_id_t log_id)
{
- return sd_journal_print(dlog_pri_to_journal_pri(prio), "%c %s: %s", dlog_pri_to_char(prio), tag, msg);
+ static const char* id_table[LOG_ID_MAX] = {
+ [LOG_ID_MAIN] = LOG_MAIN,
+ [LOG_ID_RADIO] = LOG_RADIO,
+ [LOG_ID_SYSTEM] = LOG_SYSTEM,
+ [LOG_ID_APPS] = LOG_APPS,
+ };
+
+ if (log_id < 0 || log_id >= LOG_ID_MAX || !id_table[log_id])
+ return "UNKNOWN";
+
+ return id_table[log_id];
+}
+
+static int __write_to_log_sd_journal(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
+{
+ /* XXX: sd_journal_sendv() with manually filed iov-s might be faster */
+ return sd_journal_send("MESSAGE=%s", msg,
+ "PRIORITY=%i", dlog_pri_to_journal_pri(prio),
+ "DLOG_PRIORITY=%d", prio,
+ "DLOG_TAG=%s", tag,
+ "DLOG_ID=%s", dlog_id_to_string(log_id),
+ NULL);
}
#endif
-void init_dlog_level(void)
+
+static int __read_config(char *file, int *value)
{
- char *dlog_level_env;
- char *logging_mode_env;
- if (g_logging_on) {
- logging_mode_env = getenv("TIZEN_PLATFORMLOGGING_MODE");
- if (!logging_mode_env)
- g_logging_on = 0;
- else
- g_logging_on = atoi(logging_mode_env);
+ int fd, ret;
+ char val[VALUE_MAX];
+
+ if (file == NULL || value == NULL)
+ return 0;
+ memset(val, 0, sizeof(val));
+ fd = open(file, O_RDONLY);
+ if (fd < 0) {
+ return 0;
}
- if (g_logging_on) {
- dlog_level_env = getenv("TIZEN_DLOG_LEVEL");
- if (!dlog_level_env) {
- g_dlog_level = 8;
- } else {
- g_dlog_level = atoi(dlog_level_env);
- }
- } else
- g_dlog_level = 8;
- g_dlog_level_init = 1;
+ ret = read(fd, val, 1);
+ close(fd);
+ if (ret != 1)
+ return 0;
+ *value = atoi(val);
+ return 1;
}
-static int __dlog_init(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
+
+static void __configure(void)
+{
+ int ret;
+ ret = __read_config(PLATFORMLOG_CONF, &platformlog);
+ if (!ret)
+ ret = __read_config(PLATFORMLOG_ORG_CONF, &platformlog);
+ if (!ret)
+ platformlog = 0;
+}
+
+static void __dlog_init(void)
{
pthread_mutex_lock(&log_init_lock);
- // get filtering info
- // open device
- if (write_to_log == __dlog_init) {
-
- log_fds[LOG_ID_MAIN] = open("/dev/"LOG_MAIN, O_WRONLY);
- log_fds[LOG_ID_RADIO] = open("/dev/"LOG_RADIO, O_WRONLY);
- log_fds[LOG_ID_SYSTEM] = open("/dev/"LOG_SYSTEM, O_WRONLY);
- log_fds[LOG_ID_APPS] = open("/dev/"LOG_APPS, O_WRONLY);
-
- if (log_fds[LOG_ID_MAIN] < 0 || log_fds[LOG_ID_RADIO] < 0) {
- write_to_log = __write_to_log_null;
- } else {
-#ifdef SD_JOURNAL_SUPPORT
- write_to_log = __write_to_log_sd_journal_print;
+ /* configuration */
+ __configure();
+ /* open device */
+ log_fds[LOG_ID_MAIN] = open("/dev/"LOG_MAIN, O_WRONLY);
+ log_fds[LOG_ID_RADIO] = open("/dev/"LOG_RADIO, O_WRONLY);
+ log_fds[LOG_ID_SYSTEM] = open("/dev/"LOG_SYSTEM, O_WRONLY);
+ log_fds[LOG_ID_APPS] = open("/dev/"LOG_APPS, O_WRONLY);
+ if (log_fds[LOG_ID_MAIN] < 0 || log_fds[LOG_ID_RADIO] < 0) {
+ write_to_log = __write_to_log_null;
+ } else {
+#ifdef HAVE_SYSTEMD_JOURNAL
+ write_to_log = __write_to_log_sd_journal;
#else
- write_to_log = __write_to_log_kernel;
+ write_to_log = __write_to_log_kernel;
#endif
- }
-
- if (log_fds[LOG_ID_SYSTEM] < 0)
- log_fds[LOG_ID_SYSTEM] = log_fds[LOG_ID_MAIN];
- if (log_fds[LOG_ID_APPS] < 0)
- log_fds[LOG_ID_APPS] = log_fds[LOG_ID_MAIN];
}
+
+ if (log_fds[LOG_ID_SYSTEM] < 0)
+ log_fds[LOG_ID_SYSTEM] = log_fds[LOG_ID_MAIN];
+ if (log_fds[LOG_ID_APPS] < 0)
+ log_fds[LOG_ID_APPS] = log_fds[LOG_ID_MAIN];
pthread_mutex_unlock(&log_init_lock);
- return write_to_log(log_id, prio, tag, msg);
}
int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap)
{
char buf[LOG_BUF_SIZE];
- if (!g_dlog_level_init) {
- init_dlog_level();
- }
- if (log_id < LOG_ID_APPS) {
- if(prio < g_dlog_level) {
- return 0;
- }
- } else if (LOG_ID_MAX <= log_id) {
+
+ if (LOG_ID_MAX <= log_id)
+ return 0;
+
+ if (write_to_log == NULL)
+ __dlog_init();
+
+ if (log_id != LOG_ID_APPS && !platformlog)
return 0;
- }
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
va_list ap;
char buf[LOG_BUF_SIZE];
- if (!g_dlog_level_init) {
- init_dlog_level();
- }
- if (log_id < LOG_ID_APPS) {
- if(prio < g_dlog_level) {
- return 0;
- }
- } else if (LOG_ID_MAX <= log_id) {
+ if (LOG_ID_MAX <= log_id)
+ return 0;
+
+ if (write_to_log == NULL)
+ __dlog_init();
+
+ if (log_id != LOG_ID_APPS && !platformlog)
return 0;
- }
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
return write_to_log(log_id, prio, tag, buf);
}
+
int _get_logging_on(void)
{
- return g_logging_on;
+ return 1;
}