HiLog
For example, you can use these functions to output logs of the specified log type, service domain, log tag, and log level.
Since:
1.1
Version:
1.0
Summary
Macros
Enumerations
{ HILOG_MODULE_HIVIEW = 0, , HILOG_MODULE_ACE, , HILOG_MODULE_MAX } |
|
Functions
HiLogPrint ( type, LogLevel level, unsigned int domain, const char tag, const char fmt,…) attribute((format(os_log |
Details
HILOG_DEBUG
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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.
See also:
HILOG_ERROR
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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.
See also:
HILOG_FATAL
#define HILOG_FATAL( type, ... ) ((void)[HiLogPrint]($api-api-SmartVision-Devices-HiLog.md#ga4c59c13fccc59c5821b23865fbc6380f)(LOG_CORE, [LOG_FATAL]($api-api-SmartVision-Devices-HiLog.md#ggaca1fd1d8935433e6ba2e3918214e07f9ac630750884d91cb9767ef2200bbb048b), [LOG_DOMAIN]($api-api-SmartVision-Devices-HiLog.md#ga95a1d08c807e0aada863b5298a61d08d), [LOG_TAG]($api-api-SmartVision-Devices-HiLog.md#ga7ce0df38eb467e59f209470c8f5ac4e6), __VA_ARGS__))
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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.
See also:
HILOG_INFO
Description:
Outputs informational 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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.
See also:
HILOG_WARN
Description:
Outputs warning 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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.
See also:
#define LOG_DOMAIN 0
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 0xFFFFF. If the value is beyond the range, its significant bits are automatically truncated. The recommended format is 0xAAABB, where AAA indicates the subsystem and BB indicates the module.
LOG_TAG
Description:
Defines a string constant used to identify the class, file, or service behavior.
Enumeration Type Documentation
HiLogModuleType
Description:
Enumerates logging module types.
The module type must be globally unique. A maximum of 64 module types can be defined.
HILOG_MODULE_HIVIEW | |
HILOG_MODULE_SAMGR | |
HILOG_MODULE_ACE | |
HILOG_MODULE_APP | |
HILOG_MODULE_MAX |
LogLevel
enum [LogLevel]($api-api-SmartVision-Devices-HiLog.md#gaca1fd1d8935433e6ba2e3918214e07f9)
Description:
Enumerates log levels.
You are advised to select log levels based on their respective usage scenarios:
LogType
Description:
Enumerates log types.
Currently, LOG_APP is available.
HiLogPrint()
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:
Returns:
Returns 0 or a larger value if the operation is successful; returns a value smaller than 0 otherwise.