Log Management
The header file for log management-related functionality is uav_logger.h
. This document describes the key information and usage methods for the structures and function prototypes in the uav_logger.h
file.
Table of Contents
Macro Definitions, Enumerations, and Structures
ConsoleFunc
E_UAVLoggerConsoleLogLevel
T_UAVLoggerConsoleFunction Prototypes
UAV_Logger_AddConsole
UAV_Logger_RemoveConsole
UAV_Logger_UserLogOutput
UAV_Logger_Init(void)
UAV_Logger_Send(const char* restrict fmt, ...)
Macro Definitions, Enumerations, and Structures
typedef function ConsoleFunc
- Function: The console methods that need to be registered.
- product: all
Register the log output method.
Note:
- Before registering the log output method, please test the method to ensure it can be used properly.
typedef T_UAVReturnCode (*ConsoleFunc)(const uint8_t *data, uint16_t dataLen);
typedef enum E_UAVLoggerConsoleLogLevel
Log Levels
typedef enum {
UAV_LOGGER_CONSOLE_LOG_LEVEL_ERROR = 0, /*!< Logger console error level. The method and level of the console are
associated with each other. If the level of the registered console
method is lower than this level, the level interface will not be
printed successfully. */
UAV_LOGGER_CONSOLE_LOG_LEVEL_WARN = 1, /*!< Logger console warning level.The method and level of the console are
associated with each other. If the level of the registered console
method is lower than this level, the level interface will not be
printed successfully. */
UAV_LOGGER_CONSOLE_LOG_LEVEL_INFO = 2, /*!< Logger console info level. The method and level of the console are
associated with each other. If the level of the registered console
method is lower than this level, the level interface will not be
printed successfully. */
UAV_LOGGER_CONSOLE_LOG_LEVEL_DEBUG = 3, /*!< Logger console debug level. The method and level of the console are
associated with each other. If the level of the registered console
method is lower than this level, the level interface will not be
printed successfully. */
} E_UAVLoggerConsoleLogLevel;
Function Prototypes
function UAV_Logger_AddConsole
- Function:To add console functionality and log levels to PSDK:
- product: all
Note:
- Before registering the console, users need to provide the console methods and the corresponding log levels for these methods. The log levels, from highest to lowest, are Debug, Info, Warn, and Error. The logging module can print all logs that are at or below a specified log level. Before registering the console methods, you need to test the registration module to ensure that all methods are functioning correctly.
T_UAVReturnCode UAV_Logger_AddConsole(T_UAVLoggerConsole *console);
- Parameterconsole: A pointer to the console function method.
- Return Value Returns the corresponding value based on the program's execution. For details, refer to: UAV Error Codes.
function UAV_Logger_RemoveConsole
- Function: Unregister the console.
- product: all
Note:
- Before unregistering the console, ensure that the console has been successfully registered.
T_UAVReturnCode UAV_Logger_RemoveConsole(T_UAVLoggerConsole *console);
- Parameters:none:
- Return Value: Returns the corresponding value based on the execution of the program. For details, refer to: UAV Error Codes.
function UAV_Logger_UserLogOutput
- Function: Prints logs of selected levels in a specific format through the registered method.
- product: all
Note:
- The registered method prints logs according to the specified level. If the console's level is lower than the level of the log to be printed, the log will not be successfully printed.
void UAV_Logger_UserLogOutput(uint8_t level, const char* restrict fmt, ...);
- Parameterslevel:The log level.fmt:Pointer to the log content that the user wants to print....:Variable arguments, consistent with the usage in `printf`.
- Return Valuenone:
function UAV_Logger_Send
- Function: Remote logging feature.
- product: all
Calling this function will send logs to the UAV side for storage.
Note:
- Before calling this interface,
UAV_Core_Init
must be successfully executed.
T_UAVReturnCode UAV_Logger_Send(const char* restrict fmt, ...);
- Parametersfmt:Pointer to the log content that the user needs to print....:Variable arguments, consistent with the usage of variable arguments in `printf`.
- Return Value Outputs the corresponding return value based on the program's execution status. For details, please refer to: UAV Error Codes.