Log API Usage
Defining the Log Module
- Define an ID for a log module. The value must be unique.
#define USER_DEFINE_ERROR 0x6001
The include/inc/hiaiengine/status.h file in the Atlas 500 DDK installation directory contains some module IDs. Ensure that new module IDs do not conflict with those defined in the file.
- Define the error code enumeration of the log module. If there are multiple errors, define multiple error codes in the enumeration.
typedef enum
{
USER_DEFINE_OK_CODE, USER_DEFINE_INVALID_CODE
} USER_DEFINE_CODE;
- Register the error codes defined in 2 with HIAI_DEF_ERROR_CODE (macro definition). moduleId corresponds to the module ID defined in 1. loglevel is the log level registered for the error code. The value can be HIAI_ERROR, HIAI_INFO, HIAI_DEBUG, or HIAI_WARNING. codeName corresponds to the content of the enumeration ID (excluding _CODE) of the error code in 2. codeDesc indicates the error code description. The following describes the implementation of the macro definition and use sample:
HIAI_DEF_ERROR_CODE(moduleId, logLevel, codeName, codeDesc) HIAI_DEF_ERROR_CODE(USER_DEFINE_ERROR,HIAI_ERROR,USER_DEFINE_OK,"OK")
Exporting Logs to the .dlog Log File
The Atlas 500 service software can call HIAI_ENGINE_LOG to output logs to the .dlog log file. For details, see "Logs (C++)" in the Matrix API Reference. There are eight log formats. This section describes one of them based on the log registration content. The definition and use sample are as follows:
- The function format is as follows. For details about the parameters, see Table 1.
#define HIAI_ENGINE_LOG(...) \
HIAI_ENGINE_LOG_IMPL(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
void HIAI_ENGINE_LOG_IMPL(const char* funcPointer, const char* filePath, int lineNumber, const uint32_t errorCode, const char* format, ...);
- HIAI_ENGINE_LOG is called as follows:
HIAI_ENGINE_LOG(HIAI_INVALID_INPUT_MSG, "RUNNING OK");
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot