• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# console (Log)
2
3> **NOTE**<br>
4> The APIs of this module are no longer maintained since API version 7. You are advised to use ['@ohos.hilog](js-apis-hilog.md)' instead.
5
6## console.debug
7
8debug(message: string): void
9
10Prints debug logs.
11
12- Parameters
13  | Name    | Type    | Mandatory  | Description         |
14  | ------- | ------ | ---- | ----------- |
15  | message | string | Yes   | Text to print.|
16
17
18## console.log
19
20log(message: string): void
21
22Prints debug logs.
23
24- Parameters
25  | Name    | Type    | Mandatory  | Description         |
26  | ------- | ------ | ---- | ----------- |
27  | message | string | Yes   | Text to print.|
28
29
30## console.info
31
32info(message: string): void
33
34Prints info-level logs.
35
36- Parameters
37  | Name    | Type    | Mandatory  | Description         |
38  | ------- | ------ | ---- | ----------- |
39  | message | string | Yes   | Text to print.|
40
41
42## console.warn
43
44warn(message: string): void
45
46Prints warn-level logs.
47
48- Parameters
49  | Name    | Type    | Mandatory  | Description         |
50  | ------- | ------ | ---- | ----------- |
51  | message | string | Yes   | Text to print.|
52
53
54## console.error
55
56error(message: string): void
57
58Prints error-level logs.
59
60- Parameters
61  | Name    | Type    | Mandatory  | Description         |
62  | ------- | ------ | ---- | ----------- |
63  | message | string | Yes   | Text to print.|
64
65
66## Example
67
68```
69export default {
70  clickConsole(){
71    var versionCode = 1;
72    console.info('Hello World. The current version code is ' + versionCode);
73    console.log(`versionCode: ${versionCode}`);
74    / / The following is supported since API version 6: console.log('versionCode:%d.', versionCode);
75  }
76}
77```
78
79Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
80
81![en-us_image_0000001200913929](figures/en-us_image_0000001200913929.png)
82