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 = 0x0230; 20 private static readonly TAG: string = '[PhotoApp]'; 21 public static readonly LEVEL_DEBUG = HiLog.LogLevel.DEBUG; 22 public static readonly LEVEL_INFO = HiLog.LogLevel.INFO; 23 public static readonly LEVEL_WARN = HiLog.LogLevel.WARN; 24 public static readonly LEVEL_ERROR = HiLog.LogLevel.ERROR; 25 public static readonly LEVEL_FATAL = HiLog.LogLevel.FATAL; 26 public static LOG_LEVEL = Log.LEVEL_INFO; 27 28 public static debug(TAG: string, message: string) { 29 if (this.LOG_LEVEL <= this.LEVEL_DEBUG) { 30 HiLog.debug(this.DOMAIN, this.TAG, "[" + TAG + "]: " + message); 31 } 32 } 33 34 public static info(TAG: string, message: string) { 35 if (this.LOG_LEVEL <= this.LEVEL_INFO) { 36 HiLog.info(this.DOMAIN, this.TAG, "[" + TAG + "]: " + message); 37 } 38 } 39 40 public static warn(TAG: string, message: string) { 41 if (this.LOG_LEVEL <= this.LEVEL_WARN) { 42 HiLog.warn(this.DOMAIN, this.TAG, "[" + TAG + "]: " + message); 43 } 44 } 45 46 public static error(TAG: string, message: string) { 47 if (this.LOG_LEVEL <= this.LEVEL_ERROR) { 48 HiLog.error(this.DOMAIN, this.TAG, "[" + TAG + "]: " + message); 49 } 50 } 51 52 public static fatal(TAG: string, message: string) { 53 if (this.LOG_LEVEL <= this.LEVEL_FATAL) { 54 HiLog.info(this.DOMAIN, this.TAG, "[" + TAG + "]: " + message); 55 } 56 } 57}