1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15export default class SPLogger { 16 //控制所有 17 private static isPrintLog = true 18 //控制debug 19 private static isPrintDebugLog = true 20 //控制info 21 private static isPrintInfoLog = true 22 //控制warn 23 private static isPrintWarnLog = true 24 //控制error 25 private static isPrintErrorLog = true 26 27 private static bastTag = "SmartPerf:" 28 29 //debug debug日志 30 static DEBUG(tag: string, msg: string) { 31 if (SPLogger.isPrintLog && SPLogger.isPrintDebugLog) { 32 console.debug(SPLogger.bastTag + tag + "," + msg) 33 } 34 } 35 36 //info 级别日志 37 static INFO(tag: string, msg: string) { 38 if (SPLogger.isPrintLog && SPLogger.isPrintInfoLog) { 39 console.info(SPLogger.bastTag + tag + "," + msg) 40 } 41 } 42 43 //warn 级别日志 44 static WARN(tag: string, msg: string) { 45 if (SPLogger.isPrintLog && SPLogger.isPrintWarnLog) { 46 console.warn(SPLogger.bastTag + tag + "," + msg) 47 } 48 } 49 50 //error 级别日志 51 static ERROR(tag: string, msg: string) { 52 if (SPLogger.isPrintLog && SPLogger.isPrintErrorLog) { 53 console.error(SPLogger.bastTag + tag + "," + msg) 54 } 55 } 56}