From 30062b6d59a4f46d68832426c47c6b3c5cc8cace Mon Sep 17 00:00:00 2001 From: buzhenwang Date: Tue, 2 Sep 2025 19:59:33 +0800 Subject: [PATCH] add SetLogLevel Signed-off-by: buzhenwang --- api/@ohos.hilog.d.ts | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/api/@ohos.hilog.d.ts b/api/@ohos.hilog.d.ts index 6f94ea48ed..8a6e40646f 100644 --- a/api/@ohos.hilog.d.ts +++ b/api/@ohos.hilog.d.ts @@ -364,6 +364,18 @@ declare namespace hilog { */ function setMinLogLevel(level: LogLevel): void; + /** + * Sets the lowest log level of the current application process. Different preference strategy can be set. + * + * @param { LogLevel } level log level. + * @param { PreferStrategy } prefer preference strategy. See detail in PreferStrategy. + * @syscap SystemCapability.HiviewDFX.HiLog + * @atomicservice + * @since 21 + * @arkts 1.1&1.2 + */ + function setLogLevel(level: LogLevel, prefer: PreferStrategy): void; + /** * Log level define * @@ -505,6 +517,50 @@ declare namespace hilog { */ FATAL = 7 } + + /** + * Enumerates preference strategy to be used in setLogLevel. + * + * @enum { number } + * @syscap SystemCapability.HiviewDFX.HiLog + * @crossplatform + * @atomicservice + * @since 21 + * @arkts 1.1&1.2 + */ + enum PreferStrategy { + /** + * UNSET_LOGLEVEL Used to unset SetLogLevel, then none is set + * + * @syscap SystemCapability.HiviewDFX.HiLog + * @crossplatform + * @atomicservice + * @since 21 + * @arkts 1.1&1.2 + */ + UNSET_LOGLEVEL = 0, + /** + * PREFER_CLOSE_LOG 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. + * @syscap SystemCapability.HiviewDFX.HiLog + * @crossplatform + * @atomicservice + * @since 21 + * @arkts 1.1&1.2 + */ + PREFER_CLOSE_LOG = 1, + /** + * PREFER_OPEN_LOG The actual lowest log level is determined by + * the minimum level between the new level and the system-controlled level. + * @syscap SystemCapability.HiviewDFX.HiLog + * @crossplatform + * @atomicservice + * @since 21 + * @arkts 1.1&1.2 + */ + PREFER_OPEN_LOG = 2, + } } export default hilog; \ No newline at end of file -- Gitee