1+ /**
2+ * MIT License
3+ * Copyright (C) 2021 Huawei Device Co., Ltd.
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ * The above copyright notice and this permission notice shall be included in all
11+ * copies or substantial portions of the Software.
12+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANT KIND, EXPRESS OR
13+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+ * SOFTWARE.
19+ */
20+
21+ import hilog from '@ohos.hilog';
22+
23+ class Logger {
24+ private domain : number;
25+ private prefix : string;
26+ private format : string = '%{public}s, %{public}s';
27+ private isDebug : boolean;
28+
29+ /**
30+ * constructor.
31+ *
32+ * @param Prefix Identifies the log tag.
33+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
34+ */
35+ constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
36+ this.prefix = prefix;
37+ this.domain = domain;
38+ this.isDebug = isDebug;
39+ }
40+
41+ debug(...args: string[]): void {
42+ if (this.isDebug) {
43+ hilog.debug(this.domain, this.prefix, this.format, args);
44+ }
45+ }
46+
47+ info(...args: string[]): void {
48+ hilog.info(this.domain, this.prefix, this.format, args);
49+ }
50+
51+ warn(...args: string[]) : void {
52+ hilog.warn(this.domain, this.prefix, this.format, args);
53+ }
54+
55+ error(...args: string[]) : void {
56+ hilog.error(this.domain, this.prefix, this.format, args);
57+ }
58+ }
59+
60+ export default new Logger('RNCSlider', 0xFF00, false)
0 commit comments