• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-619577

log/12-May-2024-431329

screenshots/device/12-May-2024-

.gitignoreD12-May-2024145 1211

README.mdD12-May-20241.5 KiB8057

README_zh.mdD12-May-2024527 2916

build-profile.json5D12-May-20241.1 KiB4745

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024369 1818

README.md

1# Log
2
3## Introduction
4
5This sample shows how to use log APIs to print log information and save the information to the application installation directory.
6
7## APIs
8
9```
10    import logger from '@ohos/log'
11    import { LogLevel } from '@ohos/log'
12    import { Configure }  from '@ohos/log'
13```
14
15## Usage Instruction
16
171. Configure log printing parameters.
18
19```
20  Configure = {
21    cheese: {
22        types: string[],
23        filename: string
24    }
25    defaults: {
26        appenders: string,
27        level: LogLevel
28    }
29  }
30  // If types is set to file, logs are saved to the file named by filename. appenders indicates the log tag, and level indicates the lowest log level.
31```
32
332. Initialize a **logger** instance.
34
35```
36   logger.setConfigure(configure: Configure)
37   // configure indicates the parameter configuration.
38```
39
403. Print log information of the debug level.
41
42```
43   logger.debug(value)
44   // value indicates the log content.
45```
46
474. Print log information of the info level.
48
49```
50   logger.info(value)
51   // value indicates the log content.
52```
53
545. Print log information of the warn level.
55
56```
57   logger.warn(value)
58   // value indicates the log content.
59```
60
616. Print log information of the error level.
62
63```
64   logger.error(value)
65   // value indicates the log content.
66```
67
687. Print log information of the fatal level.
69
70```
71   logger.fatal(value, bool)
72   // value indicates the log content.
73```
74
75## Constraints
76
771. This sample requires API version 8 or later.
78
792. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run.
80

README_zh.md

1# 日志打印
2
3### 介绍
4
5本示例提供日志打印类,并将日志信息保存至应用安装目录下,方便开发者进行调试。
6
7使用说明:
81. 点击log按钮即可输出日志。
9
10### 效果预览
11
12|主页|
13|----------|
14|![image](screenshots/device/index.png)|
15
16### 相关权限
17
18不涉及。
19
20
21### 依赖
22
23不涉及。
24
25### 约束与限制
26
271.本示例仅支持API9版本SDK,版本号:3.2.10.6;
28
292.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。