1.LogUtil add grade all print log;

2.clean others codecheck problems

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2022-12-15 00:59:59 -08:00
parent 42ee70ec08
commit 884b06bb32
3 changed files with 30 additions and 23 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License", * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *

View File

@ -84,7 +84,7 @@ export struct ImageKnifeComponent {
} }
private canvasHasReady:boolean = false; private canvasHasReady:boolean = false;
private firstDrawFlag:boolean = false; private firstDrawFlag:boolean = false;
private onReadyNext:Function = undefined private onReadyNext:()=>void = undefined
build() { build() {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
@ -98,7 +98,7 @@ export struct ImageKnifeComponent {
// 前提:宽高值均有效,值>0. 条件1当前宽高与上一次宽高不同 条件2:当前是第一次绘制 // 前提:宽高值均有效,值>0. 条件1当前宽高与上一次宽高不同 条件2:当前是第一次绘制
if( (this.currentHeight != this.lastHeight || this.currentWidth != this.lastWidth) || this.firstDrawFlag){ if( (this.currentHeight != this.lastHeight || this.currentWidth != this.lastWidth) || this.firstDrawFlag){
this.firstDrawFlag = false; this.firstDrawFlag = false;
LogUtil.log('ImageKnifeComponent onAreaChange isValid Canvas currentWidth =' + this.currentWidth + ' currentHeight=' + this.currentHeight) LogUtil.log('ImageKnifeComponent onAreaChange And Next To Execute. Canvas currentWidth =' + this.currentWidth + ' currentHeight=' + this.currentHeight)
this.lastWidth = this.currentWidth this.lastWidth = this.currentWidth
this.lastHeight = this.currentHeight this.lastHeight = this.currentHeight
this.imageKnifeExecute() this.imageKnifeExecute()
@ -126,11 +126,11 @@ export struct ImageKnifeComponent {
watchImageKnifeOption() { watchImageKnifeOption() {
LogUtil.log('ImageKnifeComponent watchImageKnifeOption is happened!') LogUtil.log('ImageKnifeComponent watchImageKnifeOption is happened!')
this.whetherWaitSize(); this.whetherWaitSize();
} }
/** /**
* 判断当前是否宽高,有直接重绘,没有则等待onAreaChange回调,当出现aboutToAppear第一次绘制的时候 * 判断当前是否宽高,有直接重绘,没有则等待onAreaChange回调,当出现aboutToAppear第一次绘制的时候
* 给firstDrawFlag置为true,保证size即使没有变化也要进入 请求绘制流程 * 给firstDrawFlag置为true,保证size即使没有变化也要进入 请求绘制流程
* @param drawFirst 是否是aboutToAppear第一次绘制 * @param drawFirst 是否是aboutToAppear第一次绘制
*/ */
@ -157,7 +157,7 @@ export struct ImageKnifeComponent {
* 待onReady执行的时候执行 * 待onReady执行的时候执行
* @param nextFunction 下一个方法 * @param nextFunction 下一个方法
*/ */
runNextFunction(nextFunction:Function){ runNextFunction(nextFunction:()=>void){
if(!this.canvasHasReady){ if(!this.canvasHasReady){
// canvas未初始化完成 // canvas未初始化完成
this.onReadyNext = nextFunction; this.onReadyNext = nextFunction;
@ -309,8 +309,6 @@ export struct ImageKnifeComponent {
}) })
} }
} }
} }
displayMainSource(data: ImageKnifeData) { displayMainSource(data: ImageKnifeData) {

View File

@ -13,34 +13,43 @@
* limitations under the License. * limitations under the License.
*/ */
export class LogUtil { export class LogUtil {
public static isDebug = false; 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 debug(info: string) { public static debug(message: string, ...args: any[]) {
if (this.isDebug) { if (LogUtil.mLogLevel >= LogUtil.DEBUG) {
console.debug(info) console.debug(message, args)
} }
} }
public static info(info: string) { public static info(message: string, ...args: any[]) {
if (this.isDebug) { if (LogUtil.mLogLevel >= LogUtil.INFO) {
console.info(info) console.info(message, args)
} }
} }
public static log(info: string) { public static log(message: string, ...args: any[]) {
if (this.isDebug) { if (LogUtil.mLogLevel >= LogUtil.LOG) {
console.log(info) console.log(message, args)
} }
} }
public static warn(info: string) { public static warn(message: string, ...args: any[]) {
if (this.isDebug) { if (LogUtil.mLogLevel >= LogUtil.WARN) {
console.warn(info) console.warn(message, args)
} }
} }
// error 不做拦截 // error 不做拦截
public static error(info: string) { public static error(message: string, ...args: any[]) {
console.error(info) if(LogUtil.mLogLevel >= LogUtil.ERROR) {
console.error(message, args)
}
} }
} }