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
16/**
17 * Log Util
18 *
19 * standard :
20 * 1. define TAG, recommend class name。
21 * 2. switch IS_DEBUG_ON as true, when debugging.
22 * 3. msg should be short and valuable.
23 * 4. choose appropriate function.
24 * 5. the function execute many times can not print.
25 * 6. uniqueness.
26 *
27 * @since 2022-02-18
28 */
29import Log from '@ohos.hilog';
30
31const TAG = 'MmsLog';
32const DOMAIN = 0x0800;
33
34export default class HiLog {
35
36    private static readonly COLON: string = ': ';
37
38    constructor() {
39    }
40
41    private static prefix(tag: string) {
42        return tag + this.COLON;
43    }
44
45    static d(tag: string, msg: string, ...args: any[]) {
46        Log.debug(DOMAIN, TAG, this.prefix(tag) + msg, args);
47    }
48
49    static i(tag: string, msg: string, ...args: any[]) {
50        Log.info(DOMAIN, TAG, this.prefix(tag) + msg, args);
51    }
52
53    static w(tag: string, msg: string, ...args: any[]) {
54        Log.warn(DOMAIN, TAG, this.prefix(tag) + msg, args);
55    }
56
57    static e(tag: string, msg: string, ...args: any[]) {
58        Log.error(DOMAIN, TAG, this.prefix(tag) + msg, args);
59    }
60}
61
62