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

!21115 翻译已完成19814+19889+19947+20012+20153+20203

Merge pull request !21115 from shawn_he/19528-d
......@@ -31,6 +31,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
- [Security](security/Readme-EN.md)
- [AI](ai/Readme-EN.md)
- [Connectivity](connectivity/Readme-EN.md)
- [Telephony Service](telephony/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
......
......@@ -31,6 +31,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [WebGL](webgl/webgl-overview.md)
- [Media](media/media-application-overview.md)
- [Security](security/userauth-overview.md)
- [AI](ai/mindspore-lite-js-guidelines.md)
- [Connectivity](connectivity/ipc-rpc-overview.md)
- [Telephony Service](telephony/telephony-overview.md)
- [Data Management](database/data-mgmt-overview.md)
......
......@@ -182,11 +182,11 @@ This error code is reported if an error occurs while writing received data to th
**Cause**
The application does not have the data write permission.
The application does not have the permission to write files or the file to be downloaded exceeds 5 MB.
**Solution**
Check the permissions granted to the application.
Check the application permission and the size of the file to be downloaded.
## 2300025 Failed to Upload Data
......
# HiLog
## Overview
Provides logging functions.
For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level.
\@syscap SystemCapability.HiviewDFX.HiLog
**Since:**
@syscap SystemCapability.HiviewDFX.HiLog
**Since**
8
## Summary
### Files
### File
| Name | Description |
| Name| Description|
| -------- | -------- |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>File to Include: <hilog/log.h> |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>**File to include**: <hilog/log.h><br>**Library**: libhitrace_ndk.z.so|
### Macros
| Name | Description |
| Name| Description|
| -------- | -------- |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file. |
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service. |
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. |
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. |
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. |
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. |
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file.|
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service.|
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro.|
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs INFO logs. This is a function-like macro.|
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs WARN logs. This is a function-like macro.|
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro.|
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro.|
### Enums
### Enum
| Name | Description |
| Name| Description|
| -------- | -------- |
| [LogType](#logtype) { LOG_APP = 0 } | Enumerates log types. |
| [LogLevel](#loglevel) {<br/>LOG_DEBUG = 3, LOG_INFO = 4, LOG_WARN = 5, LOG_ERROR = 6,<br/>LOG_FATAL = 7<br/>} | Enumerates log levels. |
| [LogType](#logtype) { LOG_APP= 0 } | **Log Type**|
| [LogLevel](#loglevel) { LOG_DEBUG = 3, LOG_INFO = 4, LOG_WARN = 5, LOG_ERROR = 6, LOG_FATAL =7 } | Log level.|
### Functions
| Name | Description |
| Name| Description|
| -------- | -------- |
| [OH_LOG_Print](#oh_log_print) ([LogType](#logtype) type, [LogLevel](#loglevel) level, unsigned int domain, const char *tag, const char *fmt,...) \_\_attribute\_\_((\_\_format\_\_(os_log, 5,6))) |Outputs logs. |
| [OH_LOG_IsLoggable](#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. |
| [OH_LOG_Print](#oh_log_print) ([LogType](#logtype) type, [LogLevel](#loglevel) level, unsigned int domain, const char \*tag, const char \*fmt,...) \_\_attribute\_\_((\_\_format\_\_(os\_log, 5,6))) | Outputs logs.|
| [OH_LOG_IsLoggable](#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, tag, and level can be printed.|
## Description
## Macro Description
......@@ -56,193 +63,249 @@ For example, you can use logging functions to output logs of the specified log t
### LOG_DOMAIN
```
#define LOG_DOMAIN 0
```
**Description**<br>
**Description**
Defines the service domain for a log file.
The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated.
**Since**
8
### LOG_TAG
```
#define LOG_TAG NULL
```
**Description**<br>
**Description**
Defines a string constant used to identify the class, file, or service.
**Since**
8
### OH_LOG_DEBUG
```
#define OH_LOG_DEBUG( type, ... ) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
**Description**
Outputs DEBUG logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
**Since**
8
### OH_LOG_ERROR
```
#define OH_LOG_ERROR( type, ... ) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
**Description**
Outputs ERROR logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
**Since**
8
### OH_LOG_FATAL
```
#define OH_LOG_FATAL( type, ... ) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
**Description**
Outputs FATAL logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
**Since**
8
### OH_LOG_INFO
```
#define OH_LOG_INFO( type, ... ) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
**Description**
Outputs INFO logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
**Since**
8
### OH_LOG_WARN
```
#define OH_LOG_WARN( type, ... ) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
**Description**
Outputs WARN logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
**Since**
8
## Enum Description
### LogLevel
```
enum LogLevel
```
**Description**<br>
**Description**
Enumerates log levels.
You are advised to select log levels based on their respective use cases:
You are advised to select log levels based on their respective use cases.
Log levels:
DEBUG: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
**DEBUG**: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
INFO: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
**INFO**: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
WARN: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
**WARN**: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
ERROR: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
**ERROR**: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
FATAL: indicates that a program or functionality is about to crash and the fault cannot be rectified.
**FATAL**: indicates that a program or functionality is about to crash and the fault cannot be rectified.
| Name | Description |
| Value| Description|
| -------- | -------- |
| LOG_DEBUG | DEBUG level to be used by OH_LOG_DEBUG |
| LOG_INFO | INFO level to be used by OH_LOG_INFO |
| LOG_WARN | WARN level to be used by OH_LOG_WARN |
| LOG_ERROR | ERROR level to be used by OH_LOG_ERROR |
| LOG_FATAL | FATAL level to be used by OH_LOG_FATAL |
| LOG_DEBUG | DEBUG level to be used by **OH_LOG_DEBUG**.|
| LOG_INFO | INFO level to be used by **OH_LOG_INFO**.|
| LOG_WARN | WARN level to be used by **OH_LOG_WARN**.|
| LOG_ERROR | ERROR level to be used by **OH_LOG_ERROR**.|
| LOG_FATAL | FATAL level to be used by **OH_LOG_FATAL**.|
**Since**
8
### LogType
```
enum LogType
```
**Description**<br>
**Description**
Enumerates log types.
Currently, only LOG_APP is available.
You can use this function to specify the type of output logs. Currently, only **LOG_APP** is available.
| Name | Description |
| Value| Description|
| -------- | -------- |
| LOG_APP | Application log |
| LOG_APP | Application log.|
**Since**
8
## Function Description
......@@ -250,48 +313,60 @@ Currently, only LOG_APP is available.
### OH_LOG_IsLoggable()
```
int bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level )
bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level )
```
**Description**<br>
Checks whether logs of the specified service domain, log tag, and log level can be output.
**Parameters**
**Description**
Checks whether logs of the specified service domain, tag, and level can be printed.
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| domain | Indicates the service domain of logs. |
| tag | Indicates the log tag. |
| level | Indicates the log level. |
| domain | Service domain.|
| tag | Log tag.|
| level | Log level.|
**Returns**
Returns **true** if the specified logs can be output; returns **false** otherwise.
**true** if the specified logs can be output; **false** otherwise.
**Since**
8
### OH_LOG_Print()
```
int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... )
```
**Description**<br>
**Description**
Outputs logs.
You can use this function to output logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| level | Indicates the log level, which can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**. |
| domain | Indicates the service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. |
| tag | Indicates the log tag, which is a string used to identify the class, file, or service. |
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| level | Log level. The value can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**.|
| domain | Service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.|
| tag | Log tag, which is a string used to identify the class, file, or service.|
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**Returns**
Returns **0** or a larger value if the operation is successful; returns a value smaller than **0** otherwise.
**0** or a larger value if the operation is successful; a value smaller than **0** otherwise.
**Since**
8
......@@ -492,6 +492,8 @@
- [hapsigner Overview](security/hapsigntool-overview.md)
- [hapsigner Guide](security/hapsigntool-guidelines.md)
- [HarmonyAppProvision Configuration File](security/app-provision-structure.md)
- AI
- [Using MindSpore Lite for Model Inference (JS)](ai/mindspore-lite-js-guidelines.md)
- Connectivity
- Network Management
- [Network Management Overview](connectivity/net-mgmt-overview.md)
......@@ -993,7 +995,6 @@
- [@ohos.multimodalInput.shortKey (Shortcut Key)](reference/apis/js-apis-shortKey.md)
- [@ohos.power (System Power Management)](reference/apis/js-apis-power.md)
- [@ohos.runningLock (Runninglock)](reference/apis/js-apis-runninglock.md)
- [@ohos.resourceschedule.deviceStandby (Device Standby)](reference/apis/js-apis-resourceschedule-deviceStandby.md)
- [@ohos.sensor (Sensor)](reference/apis/js-apis-sensor.md)
- [@ohos.settings (Data Item Settings)](reference/apis/js-apis-settings.md)
- [@ohos.stationary (Device Status Awareness Framework)](reference/apis/js-apis-stationary.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册