未验证 提交 a3a9a745 编写于 作者: O openharmony_ci 提交者: Gitee

!2812 翻译已完成2673#I5008Q

Merge pull request !2812 from shawn_he/b2673
# Console Logs<a name="EN-US_TOPIC_0000001127284842"></a>
# Log
## Module to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> 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.
No module is required.
## console.debug
## Required Permissions<a name="section11257113618419"></a>
debug(message: string): void
None
Prints debug logs.
## console.debug<a name="s298a3cf59a3b470dbb0742706102ced7"></a>
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.|
debug\(message: string\): void
Prints debug logs.
## console.log
- Parameters
<a name="t87748b0ba4e648079d53f9deccf4bfb2"></a>
<table><thead align="left"><tr id="rc5033ad045c14c2e806d59041aab002c"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="acf783ab6043e4ee1a7bb73b73a091e0b"><a name="acf783ab6043e4ee1a7bb73b73a091e0b"></a><a name="acf783ab6043e4ee1a7bb73b73a091e0b"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="a6736505551534b819d5a6376065a25f6"><a name="a6736505551534b819d5a6376065a25f6"></a><a name="a6736505551534b819d5a6376065a25f6"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="ac15c2a3de0e046af917cf09b48b3b46d"><a name="ac15c2a3de0e046af917cf09b48b3b46d"></a><a name="ac15c2a3de0e046af917cf09b48b3b46d"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="aeb94b88e78974288bab1b4940b50c840"><a name="aeb94b88e78974288bab1b4940b50c840"></a><a name="aeb94b88e78974288bab1b4940b50c840"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="r95c56d5cd62d4b518c3e7a3f158ed7fe"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="a7af41aec9a404f418202d90c61774825"><a name="a7af41aec9a404f418202d90c61774825"></a><a name="a7af41aec9a404f418202d90c61774825"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="aed6ae868d61349afa8f0e250108f8e47"><a name="aed6ae868d61349afa8f0e250108f8e47"></a><a name="aed6ae868d61349afa8f0e250108f8e47"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="ab72ac8cc02e34da4b717ca144fc521c1"><a name="ab72ac8cc02e34da4b717ca144fc521c1"></a><a name="ab72ac8cc02e34da4b717ca144fc521c1"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="ac53e6549d32f413e9c51cd8a53f4650a"><a name="ac53e6549d32f413e9c51cd8a53f4650a"></a><a name="ac53e6549d32f413e9c51cd8a53f4650a"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.log<a name="section146351482051"></a>
log\(message: string\): void
log(message: string): void
Prints debug logs.
- Parameter
<a name="table1852992312613"></a>
<table><thead align="left"><tr id="row953019231468"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p353020231164"><a name="p353020231164"></a><a name="p353020231164"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p15301423361"><a name="p15301423361"></a><a name="p15301423361"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p853022316618"><a name="p853022316618"></a><a name="p853022316618"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p1953072310614"><a name="p1953072310614"></a><a name="p1953072310614"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row6530823560"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p135301231364"><a name="p135301231364"></a><a name="p135301231364"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p15530523265"><a name="p15530523265"></a><a name="p15530523265"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p165301323567"><a name="p165301323567"></a><a name="p165301323567"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p853019231265"><a name="p853019231265"></a><a name="p853019231265"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.info<a name="section93434457711"></a>
info\(message: string\): void
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.|
## console.info
info(message: string): void
Prints info-level logs.
- Parameters
<a name="table611782915816"></a>
<table><thead align="left"><tr id="row1211714291989"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p41174291587"><a name="p41174291587"></a><a name="p41174291587"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p711715295817"><a name="p711715295817"></a><a name="p711715295817"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p101171729289"><a name="p101171729289"></a><a name="p101171729289"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p17117162911815"><a name="p17117162911815"></a><a name="p17117162911815"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row411762913814"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p111178291284"><a name="p111178291284"></a><a name="p111178291284"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p91181929284"><a name="p91181929284"></a><a name="p91181929284"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p12118152919810"><a name="p12118152919810"></a><a name="p12118152919810"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p18118112910811"><a name="p18118112910811"></a><a name="p18118112910811"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.warn<a name="section1363520541678"></a>
warn\(message: string\): void
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.|
## console.warn
warn(message: string): void
Prints warn-level logs.
- Parameters
<a name="table2396103815819"></a>
<table><thead align="left"><tr id="row13396183810811"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p3396153815820"><a name="p3396153815820"></a><a name="p3396153815820"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p13964389819"><a name="p13964389819"></a><a name="p13964389819"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p53961138987"><a name="p53961138987"></a><a name="p53961138987"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p0396238787"><a name="p0396238787"></a><a name="p0396238787"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9396163811811"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p33966385817"><a name="p33966385817"></a><a name="p33966385817"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p639610381280"><a name="p639610381280"></a><a name="p639610381280"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p0396183816816"><a name="p0396183816816"></a><a name="p0396183816816"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p039613818815"><a name="p039613818815"></a><a name="p039613818815"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## console.error<a name="section326012551578"></a>
error\(message: string\): void
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.|
## console.error
error(message: string): void
Prints error-level logs.
- Parameters
<a name="table79914568813"></a>
<table><thead align="left"><tr id="row899656288"><th class="cellrowborder" valign="top" width="12%" id="mcps1.1.5.1.1"><p id="p39911567816"><a name="p39911567816"></a><a name="p39911567816"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.2"><p id="p099156388"><a name="p099156388"></a><a name="p099156388"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9%" id="mcps1.1.5.1.3"><p id="p3992564819"><a name="p3992564819"></a><a name="p3992564819"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="70%" id="mcps1.1.5.1.4"><p id="p89920561088"><a name="p89920561088"></a><a name="p89920561088"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row799956389"><td class="cellrowborder" valign="top" width="12%" headers="mcps1.1.5.1.1 "><p id="p699105614811"><a name="p699105614811"></a><a name="p699105614811"></a>message</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.2 "><p id="p99925618816"><a name="p99925618816"></a><a name="p99925618816"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9%" headers="mcps1.1.5.1.3 "><p id="p189916561082"><a name="p189916561082"></a><a name="p189916561082"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.5.1.4 "><p id="p799195610812"><a name="p799195610812"></a><a name="p799195610812"></a>Text to print.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section738673813104"></a>
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.|
## Example
```
export default {
......@@ -176,13 +71,11 @@ export default {
var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
console.log(`versionCode: ${versionCode}`);
// The following is supported since API version 6.
console.log('versionCode:%d.', versionCode);
/ / The following is supported since API version 6: console.log('versionCode:%d.', versionCode);
}
}
```
Switch 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.
![](figures/log.png)
Switch 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.
![en-us_image_0000001200913929](figures/en-us_image_0000001200913929.png)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册