18779efd5Sopenharmony_ci/**
28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License.
58779efd5Sopenharmony_ci * You may obtain a copy of the License at
68779efd5Sopenharmony_ci *
78779efd5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88779efd5Sopenharmony_ci *
98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and
138779efd5Sopenharmony_ci * limitations under the License.
148779efd5Sopenharmony_ci */
158779efd5Sopenharmony_ci
168779efd5Sopenharmony_ci/**
178779efd5Sopenharmony_ci * Log Util
188779efd5Sopenharmony_ci *
198779efd5Sopenharmony_ci * standard :
208779efd5Sopenharmony_ci * 1. define TAG, recommend class name。
218779efd5Sopenharmony_ci * 2. switch IS_DEBUG_ON as true, when debugging.
228779efd5Sopenharmony_ci * 3. msg should be short and valuable.
238779efd5Sopenharmony_ci * 4. choose appropriate function.
248779efd5Sopenharmony_ci * 5. the function execute many times can not print.
258779efd5Sopenharmony_ci * 6. uniqueness.
268779efd5Sopenharmony_ci */
278779efd5Sopenharmony_ciimport Log from "@ohos.hilog";
288779efd5Sopenharmony_ci
298779efd5Sopenharmony_ciconst TAG = "ContactLog";
308779efd5Sopenharmony_ciconst DOMAIN = 0x0900;
318779efd5Sopenharmony_ci
328779efd5Sopenharmony_ciexport class HiLog {
338779efd5Sopenharmony_ci
348779efd5Sopenharmony_ci  private static readonly COLON: string = ": ";
358779efd5Sopenharmony_ci
368779efd5Sopenharmony_ci  constructor() {
378779efd5Sopenharmony_ci  }
388779efd5Sopenharmony_ci
398779efd5Sopenharmony_ci  private static prefix(tag: string) {
408779efd5Sopenharmony_ci    return tag + this.COLON;
418779efd5Sopenharmony_ci  }
428779efd5Sopenharmony_ci
438779efd5Sopenharmony_ci  static d(tag: string, msg: string, ...args: any[]) {
448779efd5Sopenharmony_ci    Log.debug(DOMAIN, TAG, this.prefix(tag) + msg, args);
458779efd5Sopenharmony_ci  }
468779efd5Sopenharmony_ci
478779efd5Sopenharmony_ci  static i(tag: string, msg: string, ...args: any[]) {
488779efd5Sopenharmony_ci    Log.info(DOMAIN, TAG, this.prefix(tag) + msg, args);
498779efd5Sopenharmony_ci  }
508779efd5Sopenharmony_ci
518779efd5Sopenharmony_ci  static w(tag: string, msg: string, ...args: any[]) {
528779efd5Sopenharmony_ci    Log.warn(DOMAIN, TAG, this.prefix(tag) + msg, args);
538779efd5Sopenharmony_ci  }
548779efd5Sopenharmony_ci
558779efd5Sopenharmony_ci  static e(tag: string, msg: string, ...args: any[]) {
568779efd5Sopenharmony_ci    Log.error(DOMAIN, TAG, this.prefix(tag) + msg, args);
578779efd5Sopenharmony_ci  }
588779efd5Sopenharmony_ci}
598779efd5Sopenharmony_ci
60