提交 44f57979 编写于 作者: S shawn_he

uddate docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 78eeee8e
# HiLog
The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs.
This document describes only API functions. For details about log printing requirements, see [Logging Guide](../../../contribute/OpenHarmony-Log-guide.md).
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -42,7 +41,7 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO);
## LogLevel
Log level.
Enumerates the log levels.
**System capability**: SystemCapability.HiviewDFX.HiLog
......@@ -70,7 +69,7 @@ DEBUG logs are not recorded in official versions by default. They are available
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -101,7 +100,7 @@ Prints INFO logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -132,7 +131,7 @@ Prints WARN logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -163,7 +162,7 @@ Prints ERROR logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -194,7 +193,7 @@ Prints FATAL logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import radio from '@ohos.telephony.radio'
```
......@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP
**Example**
```
```js
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return
**Example**
```
```js
let slotId = 0;
let promise = radio.getRadioTech(slotId);
promise.then(data => {
......@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
radio.getNetworkState((err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
let slotId = 0;
radio.getNetworkState(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkState(slotId);
promise.then(data => {
......@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => {
......@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => {
......@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
radio.getPrimarySlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
let promise = radio.getPrimarySlotId();
promise.then(data => {
console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
let promise = radio.getSignalInformation(slotId);
promise.then(data => {
......@@ -405,10 +405,10 @@ Checks whether the current device supports 5G \(NR\).
**Example**
```
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
console.log("Result: "+ result);
```
......@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Example**
```
```js
radio.isRadioOn((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Example**
```
```js
let slotId = 0;
radio.isRadioOn(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t
**Example**
```
```js
let slotId = 0;
let promise = radio.isRadioOn(slotId);
promise.then(data => {
......@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r
**Example**
```
```js
let slotId = 0;
radio.getOperatorName(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result.
**Example**
```
```js
let slotId = 0;
let promise = radio.getOperatorName(slotId);
promise.then(data => {
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import sim from '@ohos.telephony.sim';
```
......@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an
**Example**
```
```js
sim.isSimActive(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a
**Example**
```
```js
let promise = sim.isSimActive(0);
promise.then(data => {
console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
......@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example**
```
```js
sim.getDefaultVoiceSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example**
```
```js
let promise = sim.getDefaultVoiceSlotId();
promise.then(data => {
console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example**
```
```js
sim.hasOperatorPrivileges(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example**
```
```js
let promise = sim.hasOperatorPrivileges(0);
promise.then(data => {
console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
......@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example**
```
```js
sim.getISOCountryCodeForSim(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example**
```
```js
let promise = sim.getISOCountryCodeForSim(0);
promise.then(data => {
console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
......@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
**Example**
```
```js
sim.getSimOperatorNumeric(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi
**Example**
```
```js
let promise = sim.getSimOperatorNumeric(0);
promise.then(data => {
console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
......@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
**Example**
```
```js
sim.getSimSpn(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t
**Example**
```
```js
let promise = sim.getSimSpn(0);
promise.then(data => {
console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
......@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async
**Example**
```
```js
sim.getSimState(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis
**Example**
```
```js
let promise = sim.getSimState(0);
promise.then(data => {
console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
......@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr
**Example**
```
```js
sim.getCardType(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise
**Example**
```
```js
let promise = sim.getCardType(0);
promise.then(data => {
console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
......@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Example**
```
```js
sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a
**Example**
```
```js
let promise = sim.hasSimCard(0);
promise.then(data => {
console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
......@@ -520,8 +520,8 @@ Obtains the number of card slots.
**Example**
```
console.log(sim.getMaxSimCount())
```js
console.log("Result: "+ sim.getMaxSimCount())
```
......
......@@ -23,7 +23,7 @@ import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
// When receiving the on('open') event, the client can use the send() API to communicate with the server.
ws.send("Hello, server!", (err, value) => {
if (!err) {
......@@ -47,7 +47,7 @@ ws.on('message', (err, value) => {
}
});
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
console.log("on close, code is " + value['code'] + ", reason is " + value['reason']);
});
ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err));
......@@ -393,7 +393,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us
```js
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
});
```
......@@ -421,7 +421,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u
```js
let ws = webSocket.createWebSocket();
let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
}
ws.on('open', callback1);
// You can pass the callback of the on function to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
......@@ -505,7 +505,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
```js
let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
console.log("on close, code is " + value['code'] + ", reason is " + value['reason']);
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册