diff --git a/CHANGELOG.md b/CHANGELOG.md index f912a80..1eada43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别 - 修复加载错误图后未去请求排队队列中的请求 - 子线程本地Resource参数类型转换成number +- 修改使用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