diff --git a/hiviewdfx/hilog/include/hilog/log.h b/hiviewdfx/hilog/include/hilog/log.h index 1c4cda70470867aa3a89f12d025251f6c9742567..0aa747734a09aae4cdb54d2607e8674d49aff9ad 100644 --- a/hiviewdfx/hilog/include/hilog/log.h +++ b/hiviewdfx/hilog/include/hilog/log.h @@ -133,6 +133,30 @@ typedef enum { LOG_FATAL = 7, } LogLevel; +/** + * @brief Enumerates preference strategy to be used in {@link OH_LOG_SetLogLevel}. + * + * You are advised to select preference strategy based on their respective usage scenarios. + * + * @since 21 + */ +typedef enum { + /** Used to unset SetLogLevel, then none is set + */ + UNSET_LOGLEVEL = 0, + /** + * The actual lowest log level is determined by + * the maximum level between the new level and the system-controlled level. + * This is equivalent to calling OH_LOG_SetMinLogLevel. + */ + PREFER_CLOSE_LOG = 1, + /** + * The actual lowest log level is determined by + * the minimum level between the new level and the system-controlled level. + */ + PREFER_OPEN_LOG = 2, +} PreferStrategy; + /** * @brief Outputs logs. * @@ -351,6 +375,15 @@ void OH_LOG_SetCallback(LogCallback callback); */ void OH_LOG_SetMinLogLevel(LogLevel level); +/** + * @brief Sets the lowest log level of the current application process. Different preference strategy can be set. + * + * @param level log level. + * @param prefer preference strategy. See {@link PreferStrategy}. + * @since 21 + */ +void OH_LOG_SetLogLevel(LogLevel level, PreferStrategy prefer); + #ifdef __cplusplus } #endif diff --git a/hiviewdfx/hilog/libhilog.ndk.json b/hiviewdfx/hilog/libhilog.ndk.json index 0d14010e04c1ea7dffaef8c2a1e89a2dc7a6e037..2f06e93a984744041fa91f00fe9b0f2ec28afb60 100644 --- a/hiviewdfx/hilog/libhilog.ndk.json +++ b/hiviewdfx/hilog/libhilog.ndk.json @@ -19,5 +19,9 @@ }, { "name": "OH_LOG_SetMinLogLevel" + }, + { + "first_instroduced":"21", + "name": "OH_LOG_SetLogLevel" } ]