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 18const DOMAIN: number = 0x0220; 19const TAG: string = 'Photos'; 20const COLON = ': '; 21 22export class Log { 23 static debug(className: string, message: string, ...args: string[]): boolean { 24 if (HiLog.isLoggable(DOMAIN, TAG, HiLog.LogLevel.DEBUG)) { 25 HiLog.debug(DOMAIN, TAG, className + COLON + message, args); 26 return true; 27 } 28 return false; 29 } 30 31 static info(className: string, message: string, ...args: string[]): boolean { 32 if (HiLog.isLoggable(DOMAIN, TAG, HiLog.LogLevel.INFO)) { 33 HiLog.info(DOMAIN, TAG, className + COLON + message, args); 34 return true; 35 } 36 return false; 37 } 38 39 static warn(className: string, message: string, ...args: string[]): boolean { 40 if (HiLog.isLoggable(DOMAIN, TAG, HiLog.LogLevel.WARN)) { 41 HiLog.warn(DOMAIN, TAG, className + COLON + message, args); 42 return true; 43 } 44 return false; 45 } 46 47 static error(className: string, message: string, ...args: string[]): boolean { 48 if (HiLog.isLoggable(DOMAIN, TAG, HiLog.LogLevel.ERROR)) { 49 HiLog.error(DOMAIN, TAG, className + COLON + message, args); 50 return true; 51 } 52 return false; 53 } 54 55 static fatal(className: string, message: string, ...args: string[]): boolean { 56 if (HiLog.isLoggable(DOMAIN, TAG, HiLog.LogLevel.FATAL)) { 57 HiLog.fatal(DOMAIN, TAG, className + COLON + message, args); 58 return true; 59 } 60 return false; 61 } 62} 63