Add __dlog_sec_print() to keep backward compatibility with existing MCD in-house... 03/217003/5 accepted/tizen/unified/20191107.051421 submit/tizen/20191106.015848
authorHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 5 Nov 2019 09:47:21 +0000 (18:47 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 6 Nov 2019 01:48:04 +0000 (01:48 +0000)
.#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
({ do { \
      __dlog_sec_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
} while (0); })

root@localhost:/usr/apps/com.samsung.w-manager-service/bin# ./w-manager-service
appcore: Failed to get application ID - pid(3962)
./w-manager-service: symbol lookup error: ./w-manager-service: undefined symbol: __dlog_sec_print

root@HyotaekShim:/platform/AppStoreWhitelist/20191106# grep -r __dlog_sec_print
000001044261_com.samsung.w-dialer2_100015.txt:__dlog_sec_print
000004264895_com.samsung.tizen.bixby-voice_210200007.txt:__dlog_sec_print
000001913406_com.samsung.w-spotify_300002.txt:__dlog_sec_print
000001902170_com.samsung.w-spotify_300001.txt:__dlog_sec_print
000002736570_com.samsung.w-manager-service_500300013.txt:__dlog_sec_print
000002420102_com.samsung.samsung-pay-app_100400303.txt:__dlog_sec_print
000001915993_com.samsung.w-spotify_300002.txt:__dlog_sec_print
000002750274_com.samsung.w-logs2_100300011.txt:__dlog_sec_print
000002738273_com.samsung.w-contacts2_100200074.txt:__dlog_sec_print
...

Change-Id: Ieda4e759213ab50810540574d98f72bb0491c6c9
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
include/dlog-internal.h
src/libdlog/log.c

index b52e2e9..b6d4e3c 100644 (file)
@@ -75,7 +75,7 @@ static inline int __dlog_no_print(const char *fmt __attribute__((unused)), ...)
 #undef SECURE_LOG_
 #define SECURE_LOG_(id, prio, tag, fmt, arg...) \
        ({ do { \
-               __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
+               __dlog_sec_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
        } while (0); })
 
 // ---------------------------------------------------------------------
@@ -378,6 +378,33 @@ static inline int __dlog_no_print(const char *fmt __attribute__((unused)), ...)
 #pragma GCC diagnostic error "-Wformat"
 int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
 
+/*
+ * The stuff in the rest of this file should not be used directly.
+ */
+/**
+ * @internal
+ * @brief     Send log.
+ * @details   Use SECURE_LOG(), SECURE_SLOG(), SECURE_RLOG() family
+ *                       not to use __dlog_sec_print() directly
+ * @remarks   Must not use this API directly. use macros instead.
+ * @param[in] log_id log device id
+ * @param[in] prio priority
+ * @param[in] tag tag
+ * @param[in] fmt format string
+ * @return    Operation result
+ * @retval    0>= Success
+ * @retval    -1  Error
+ * @pre       none
+ * @post      none
+ * @see       __dlog_sec_print
+ * @code
+    #define LOG_TAG USR_TAG
+    #include<dlog-internal.h>
+     __dlog_sec_print(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly");
+ * @endcode
+ */
+int __dlog_sec_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
+
 /**
  * @internal
  * @brief     Send log with va_list.
index 7531e37..755429e 100644 (file)
@@ -375,6 +375,26 @@ int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ..
        return ret;
 }
 
+/**
+ * @brief Print log
+ * @details Print a log line
+ * @param[in] log_id The target buffer ID
+ * @param[in] prio Priority
+ * @param[in] tag tag
+ * @param[in] fmt Format (same as printf)
+ * @return Bytes written, or negative error
+ */
+int __dlog_sec_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       int ret = __dlog_vprint(log_id, prio, tag, fmt, ap);
+       va_end(ap);
+
+       return ret;
+}
+
 int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap)
 {
        return __write_to_log(LOG_ID_APPS, prio, tag, fmt, ap, false);