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 */ 15 16import HiLog from "@ohos.hilog" 17 18export class Log { 19 private static readonly DOMAIN = 0x0200 20 private static readonly TAG: string = '[CameraApp]' 21 22 public static readonly LEVEL_DEBUG = 0; 23 public static readonly LEVEL_LOG = 1; 24 public static readonly LEVEL_INFO = 2; 25 public static readonly LEVEL_WARN = 3; 26 public static readonly LEVEL_ERROR = 4; 27 public static LOG_LEVEL = Log.LEVEL_LOG; 28 29 30 public static debug(message: string) { 31 if (this.LOG_LEVEL <= this.LEVEL_DEBUG) { 32 HiLog.debug(this.DOMAIN, this.TAG, message) 33 } 34 } 35 36 public static log(message: string) { 37 if (this.LOG_LEVEL <= this.LEVEL_LOG) { 38 HiLog.info(this.DOMAIN, this.TAG, message) 39 } 40 } 41 42 public static info(message: string) { 43 if (this.LOG_LEVEL <= this.LEVEL_INFO) { 44 HiLog.info(this.DOMAIN, this.TAG, message) 45 } 46 } 47 48 public static warn(message: string) { 49 if (this.LOG_LEVEL <= this.LEVEL_WARN) { 50 HiLog.warn(this.DOMAIN, this.TAG, message) 51 } 52 } 53 54 public static error(message: string) { 55 if (this.LOG_LEVEL <= this.LEVEL_ERROR) { 56 HiLog.error(this.DOMAIN, this.TAG, message) 57 } 58 } 59}