From 1369a0fd32651314fcc887bfe67c5a9513521f05 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Fri, 3 Nov 2023 15:42:20 +0800 Subject: [PATCH] add hilog callback Signed-off-by: liuyifei --- hiviewdfx/hilog/include/hilog/log.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hiviewdfx/hilog/include/hilog/log.h b/hiviewdfx/hilog/include/hilog/log.h index 26049d945..7452137c2 100644 --- a/hiviewdfx/hilog/include/hilog/log.h +++ b/hiviewdfx/hilog/include/hilog/log.h @@ -246,6 +246,34 @@ bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); */ #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +/** + * @brief Defines the function pointer type for the user-defined log processing function. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param msg Indicates the log message itself, which is a formatted log string. + * @since 11 + */ +typedef void (*LogCallback)(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg); + +/** + * @brief Set the user-defined log processing function. + * + * After calling this function, the callback function implemented by the user can receive all hilogs of the + * current process. + * Note that it will not change the default behavior of hilog logs of the current process, no matter whether this + * interface is called or not. \n + * + * @param callback Indicates the callback function implemented by the user. If you do not need to process hilog logs, + * you can transfer a null pointer. + * @since 11 + */ +void OH_LOG_SetCallback(LogCallback callback); + #ifdef __cplusplus } #endif -- Gitee