Header File Usage Example
- The log APIs provided in log.h and log.hdr should be used directly; secondary encapsulation is prohibited.
- Do not pass a null pointer to the log content.
- If log printing is required, the Hydra source file must include the FILE_ID macro definition for the file name and reference the log header files. For example, the FILE_ID macro definition of fullnat_ovs_hdr needs to be added to the fullnat_ovs.hdr source file.
- The 0x%x format must be used for printing variables, and the number of variables cannot exceed 4.
- flexda_sdk/include/dsl/log.hdr: Provides the declarations for
DSL code log APIs, supporting log levels ERR, WARN, INFO, and DEBUG. - flexda_sdk/include/dfx/log.h: Provides the definitions for DSL code log APIs.
Example
The following takes fullnat_ovs.hdr for example.
#include "logfile_id_user_define.hdr"
#include "log.hdr"
#define FILE_ID fullnat_ovs_hdr
control MyPrePipe(in hdr_fix_headers hdr) {
...
apply {
USER_LOG(ERR, "XXX.\n");
bit<32> value1 = 1;
bit<32> value2 = 1;
USER_LOG(WARN, "XXX value1 0x%x value2 0x%x.\n", value1, value2);
}
...
}
Parent topic: OVS Code Project Description