Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-2024145

AppScope/H25-Oct-20244 KiB

build-profile.json5H A D25-Oct-20241.1 KiB

entry/H25-Oct-20244 KiB

hvigor/H25-Oct-20244 KiB

hvigorfile.tsH A D25-Oct-2024763

hvigorwH A D25-Oct-20242.1 KiB

hvigorw.batH A D25-Oct-20242 KiB

log/H25-Oct-20244 KiB

oh-package.json5H A D25-Oct-2024812

ohosTest.mdH A D25-Oct-2024381

README.mdH A D25-Oct-20241.5 KiB

README_zh.mdH A D25-Oct-20242.3 KiB

screenshots/device/H25-Oct-20244 KiB

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 9 or later.
78
792. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run.
80