修改使用hilog记录日志,默认打开debug级别的日志,增加可维侧性

Signed-off-by: Madixin <madixin@huawei.com>
This commit is contained in:
Madixin 2024-08-27 16:37:47 +08:00
parent 6612dea1d5
commit 47c178fe1f
4 changed files with 13 additions and 28 deletions

View File

@ -1,6 +1,7 @@
## 3.1.0-rc.3
- 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别
- 修复加载错误图后未去请求排队队列中的请求
- 修改使用hilog记录日志默认打开debug级别的日志
## 3.1.0-rc.2
- 修复宽高不等svg图片显示有毛边

View File

@ -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())

View File

@ -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)
}
}

View File

@ -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)
}
}