1315b9658Sopenharmony_ci/**
2315b9658Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3315b9658Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4315b9658Sopenharmony_ci * you may not use this file except in compliance with the License.
5315b9658Sopenharmony_ci * You may obtain a copy of the License at
6315b9658Sopenharmony_ci *
7315b9658Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8315b9658Sopenharmony_ci *
9315b9658Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10315b9658Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11315b9658Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12315b9658Sopenharmony_ci * See the License for the specific language governing permissions and
13315b9658Sopenharmony_ci * limitations under the License.
14315b9658Sopenharmony_ci */
15315b9658Sopenharmony_ci
16315b9658Sopenharmony_ciimport hiLog from '@ohos.hilog';
17315b9658Sopenharmony_ciimport ExtensionAbility from '@ohos.app.ability.ExtensionAbility';
18315b9658Sopenharmony_ci
19315b9658Sopenharmony_ciconst DOMAIN: number = 0x0500;
20315b9658Sopenharmony_ciconst TAG = 'SettingsData';
21315b9658Sopenharmony_ci
22315b9658Sopenharmony_ci/**
23315b9658Sopenharmony_ci *  升级到4.0.10 删除:
24315b9658Sopenharmony_ci */
25315b9658Sopenharmony_ciexport interface CommonEventData{
26315b9658Sopenharmony_ci  event: string;
27315b9658Sopenharmony_ci  bundleName?: string;
28315b9658Sopenharmony_ci  code?: number;
29315b9658Sopenharmony_ci  data?: string;
30315b9658Sopenharmony_ci  parameters?: { [key: string]: string | number | boolean | null | undefined };
31315b9658Sopenharmony_ci}
32315b9658Sopenharmony_ci
33315b9658Sopenharmony_ci/**
34315b9658Sopenharmony_ci * Basic log class
35315b9658Sopenharmony_ci */
36315b9658Sopenharmony_ciexport class Log {
37315b9658Sopenharmony_ci  /**
38315b9658Sopenharmony_ci   * Outputs info-level logs.
39315b9658Sopenharmony_ci   *
40315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
41315b9658Sopenharmony_ci   * @param format Indicates the log format string.
42315b9658Sopenharmony_ci   * @param args Indicates the log parameters.
43315b9658Sopenharmony_ci   * @since 7
44315b9658Sopenharmony_ci   */
45315b9658Sopenharmony_ci  static info(format: string, ...args: string[]): void {
46315b9658Sopenharmony_ci    if (Log.isLoggable(hiLog.LogLevel.INFO)) {
47315b9658Sopenharmony_ci      hiLog.info(DOMAIN, TAG, format, args);
48315b9658Sopenharmony_ci    }
49315b9658Sopenharmony_ci  }
50315b9658Sopenharmony_ci
51315b9658Sopenharmony_ci  /**
52315b9658Sopenharmony_ci   * Outputs debug-level logs.
53315b9658Sopenharmony_ci   *
54315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
55315b9658Sopenharmony_ci   * @param format Indicates the log format string.
56315b9658Sopenharmony_ci   * @param args Indicates the log parameters.
57315b9658Sopenharmony_ci   * @since 7
58315b9658Sopenharmony_ci   */
59315b9658Sopenharmony_ci  static debug(format: string, ...args: string[]): void {
60315b9658Sopenharmony_ci    if (Log.isLoggable(hiLog.LogLevel.DEBUG)) {
61315b9658Sopenharmony_ci      hiLog.debug(DOMAIN, TAG, format, args);
62315b9658Sopenharmony_ci    }
63315b9658Sopenharmony_ci  }
64315b9658Sopenharmony_ci
65315b9658Sopenharmony_ci  /**
66315b9658Sopenharmony_ci   * Outputs warning-level logs.
67315b9658Sopenharmony_ci   *
68315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
69315b9658Sopenharmony_ci   * @param format Indicates the log format string.
70315b9658Sopenharmony_ci   * @param args Indicates the log parameters.
71315b9658Sopenharmony_ci   * @since 7
72315b9658Sopenharmony_ci   */
73315b9658Sopenharmony_ci  static warn(format: string, ...args: string[]): void {
74315b9658Sopenharmony_ci    if (Log.isLoggable(hiLog.LogLevel.WARN)) {
75315b9658Sopenharmony_ci      hiLog.warn(DOMAIN, TAG, format, args);
76315b9658Sopenharmony_ci    }
77315b9658Sopenharmony_ci  }
78315b9658Sopenharmony_ci
79315b9658Sopenharmony_ci  /**
80315b9658Sopenharmony_ci   * Outputs error-level logs.
81315b9658Sopenharmony_ci   *
82315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
83315b9658Sopenharmony_ci   * @param format Indicates the log format string.
84315b9658Sopenharmony_ci   * @param args Indicates the log parameters.
85315b9658Sopenharmony_ci   * @since 7
86315b9658Sopenharmony_ci   */
87315b9658Sopenharmony_ci  static error(format: string, ...args: string[]): void {
88315b9658Sopenharmony_ci    if (Log.isLoggable(hiLog.LogLevel.ERROR)) {
89315b9658Sopenharmony_ci      hiLog.error(DOMAIN, TAG, format, args);
90315b9658Sopenharmony_ci    }
91315b9658Sopenharmony_ci  }
92315b9658Sopenharmony_ci
93315b9658Sopenharmony_ci  /**
94315b9658Sopenharmony_ci   * Outputs fatal-level logs.
95315b9658Sopenharmony_ci   *
96315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
97315b9658Sopenharmony_ci   * @param format Indicates the log format string.
98315b9658Sopenharmony_ci   * @param args Indicates the log parameters.
99315b9658Sopenharmony_ci   * @since 7
100315b9658Sopenharmony_ci   */
101315b9658Sopenharmony_ci  static fatal(format: string, ...args: string[]): void {
102315b9658Sopenharmony_ci    if (Log.isLoggable(hiLog.LogLevel.FATAL)) {
103315b9658Sopenharmony_ci      hiLog.fatal(DOMAIN, TAG, format, args);
104315b9658Sopenharmony_ci    }
105315b9658Sopenharmony_ci  }
106315b9658Sopenharmony_ci
107315b9658Sopenharmony_ci  /**
108315b9658Sopenharmony_ci   * Checks whether logs of the specified tag, and level can be printed.
109315b9658Sopenharmony_ci   *
110315b9658Sopenharmony_ci   * @param tag Identifies the log tag.
111315b9658Sopenharmony_ci   * @param level log level
112315b9658Sopenharmony_ci   * @since 7
113315b9658Sopenharmony_ci   */
114315b9658Sopenharmony_ci  private static isLoggable(level: hiLog.LogLevel): boolean {
115315b9658Sopenharmony_ci    return hiLog.isLoggable(DOMAIN, TAG, level);
116315b9658Sopenharmony_ci  }
117315b9658Sopenharmony_ci}
118