From 47c178fe1f19968d4425f000906b25407f2995e2 Mon Sep 17 00:00:00 2001 From: Madixin Date: Tue, 27 Aug 2024 16:37:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8hilog?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=89=93=E5=BC=80debug=E7=BA=A7=E5=88=AB=E7=9A=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8F=AF=E7=BB=B4=E4=BE=A7?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Madixin --- CHANGELOG.md | 1 + .../main/ets/entryability/EntryAbility.ets | 1 - library/src/main/ets/utils/FileCache.ets | 6 ++-- library/src/main/ets/utils/LogUtil.ets | 33 +++++-------------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0e44f3..a3d127e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 3.1.0-rc.3 - 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别 - 修复加载错误图后未去请求排队队列中的请求 +- 修改使用hilog记录日志,默认打开debug级别的日志 ## 3.1.0-rc.2 - 修复宽高不等svg图片显示有毛边 diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 488dcce..e19ffa7 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -47,7 +47,6 @@ export default class EntryAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - LogUtil.mLogLevel = LogUtil.ALL // 初始化ImageKnife的文件缓存 await InitImageKnife.init(this.context) ImageKnife.getInstance().setEngineKeyImpl(new CustomEngineKeyImpl()) diff --git a/library/src/main/ets/utils/FileCache.ets b/library/src/main/ets/utils/FileCache.ets index f4e5fcc..957a2c0 100644 --- a/library/src/main/ets/utils/FileCache.ets +++ b/library/src/main/ets/utils/FileCache.ets @@ -232,18 +232,18 @@ export class FileCache { } else if (value != undefined) { this.currentMemory -= value.byteLength - LogUtil.info("FileCache removeMemorySize: " + value.byteLength + " currentMemory:" + this.currentMemory) + LogUtil.debug("FileCache removeMemorySize: " + value.byteLength + " currentMemory:" + this.currentMemory) } } private addMemorySize(value: ArrayBuffer | number): void { if (typeof value == "number") { this.currentMemory += value - LogUtil.info("FileCache addMemorySize: " + value + " currentMemory:" + this.currentMemory) + LogUtil.debug("FileCache addMemorySize: " + value + " currentMemory:" + this.currentMemory) } else if (value != undefined) { this.currentMemory += value.byteLength - LogUtil.info("FileCache addMemorySize: " + value.byteLength + " currentMemory:" + this.currentMemory) + LogUtil.debug("FileCache addMemorySize: " + value.byteLength + " currentMemory:" + this.currentMemory) } } diff --git a/library/src/main/ets/utils/LogUtil.ets b/library/src/main/ets/utils/LogUtil.ets index 02c2d39..d59f582 100644 --- a/library/src/main/ets/utils/LogUtil.ets +++ b/library/src/main/ets/utils/LogUtil.ets @@ -12,44 +12,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { hilog } from '@kit.PerformanceAnalysisKit'; + export class LogUtil { - public static OFF: number = 1 - public static LOG: number = 2 - public static DEBUG: number = 3 - public static INFO: number = 4 - public static WARN: number = 5 - public static ERROR: number = 6 - public static ALL: number = 7 - public static mLogLevel: number = LogUtil.OFF; - public static TAG: string = "ImageKnife:: "; + public static readonly DOMAIN: number = 0xD002220; + public static readonly TAG: string = "ImageKnife::"; public static debug(message: string, ...args: Object[]) { - if (LogUtil.mLogLevel >= LogUtil.DEBUG) { - console.debug(LogUtil.TAG + message, args) - } + hilog.debug(LogUtil.DOMAIN, LogUtil.TAG, message, args) } public static info(message: string, ...args: Object[]) { - if (LogUtil.mLogLevel >= LogUtil.INFO) { - console.info(LogUtil.TAG + message, args) - } + hilog.info(LogUtil.DOMAIN, LogUtil.TAG, message, args) } public static log(message: string, ...args: Object[]) { - if (LogUtil.mLogLevel >= LogUtil.LOG) { - console.log(LogUtil.TAG + message, args) - } + hilog.debug(LogUtil.DOMAIN, LogUtil.TAG, message, args) } public static warn(message: string, ...args: Object[]) { - if (LogUtil.mLogLevel >= LogUtil.WARN) { - console.warn(LogUtil.TAG + message, args) - } + hilog.warn(LogUtil.DOMAIN, LogUtil.TAG, message, args) } public static error(message: string, ...args: Object[]) { - if (LogUtil.mLogLevel >= LogUtil.ERROR) { - console.error(LogUtil.TAG + message, args) - } + hilog.error(LogUtil.DOMAIN, LogUtil.TAG, message, args) } } \ No newline at end of file