日志管理
日志管理相关功能的头文件为 uav_logger.h
,本文档描述了 uav_logger.h
文件中结构体和函数原型的关键信息和使用方法。
目录
宏定义、枚举与结构体
ConsoleFunc
E_UAVLoggerConsoleLogLevel
T_UAVLoggerConsole函数原型
UAV_Logger_AddConsole
UAV_Logger_RemoveConsole
UAV_Logger_UserLogOutput
UAV_Logger_Init(void)
UAV_Logger_Send(const char* restrict fmt, ...)
宏定义、枚举与结构体
typedef function ConsoleFunc
- 功能: 需要被注册的控制台方法。
- product: all。
注册日志输出方式。
说明:
- 在注册日志输出方式前,请先测试需要注册的方法,以确保他们能被正常使用。
typedef T_AutelReturnCode (*ConsoleFunc)(const uint8_t *data, uint16_t dataLen);
typedef enum E_UAVLoggerConsoleLogLevel
日志等级
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 UAV_Logger_AddConsole
- 功能: 为 PSDK 添加控制台功能与等级。
- product: all。
说明:
- 在注册控制台前,用户需要提供控制台方法以及与该方法相关的等级。日志等级从高到低为 Debug, Info, Warn 和 Error。日志功能模块可以打印所有不高于特定级别的日志。在注册控制台方法前,你需要测试注册模块以确保所有的方法是正常的。
T_AutelReturnCode UAV_Logger_AddConsole(T_UAVLoggerConsole *console);
- 参数console:指向控制台功能的方法。
- 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码。
function UAV_Logger_RemoveConsole
- 功能: 注销控制台。
- product: all。
说明:
- 在注销控制台前,需确保已经成功注册了控制台。
T_AutelReturnCode UAV_Logger_RemoveConsole(T_UAVLoggerConsole *console);
- 参数none:
- 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码。
function UAV_Logger_UserLogOutput
- 功能: 通过注册方法打印输出特定格式的选定等级的日志
- product: all。
说明:
- 注册的方法是按照对应级别打印的。如果控制台的级别比需要被打印的 log 的级别低,将不会打印成功。
void UAV_Logger_UserLogOutput(uint8_t level, const char* restrict fmt, ...);
- 参数level:日志等级。fmt:指向用户需打印的日志内容。...:可变参数,与printf 中的可变参数用法一致。
- 返回值none:
function UAV_Logger_Send
- 功能: 远程日志功能。
- product: all。
调用此函数,可将日志发送到无人机端进行存储
说明:
- 调用此接口前,需执行
UAV_Core_Init
成功。
T_AutelReturnCode UAV_Logger_Send(const char* restrict fmt, ...);
- 参数fmt:指向用户需打印的日志内容。...:可变参数,与printf 中的可变参数用法一致。
- 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码。