<< 点击显示目录 >> 主页 exOS使用助手 > exOS Automation Help > Development > Programming > Logging > Local defines |
函数exos_log_error()、exos_log_success() 等的编写可能会相当繁琐,因为它们必须传递一个指向日志句柄的指针,并为每条信息指定日志类型。因此,建议每个应用程序都定义自己的简化日志宏,例如
#define INFO(_format_, ...) exos_log_info(&logger, EXOS_LOG_TYPE_USER, _format_, ##__VA_ARGS__);
#define DEBUG(_format_, ...) exos_log_info(&logger, EXOS_LOG_TYPE_USER + EXOS_LOG_TYPE_VERBOSE, _format_, ##__VA_ARGS__);
...
int main(void)
{
exos_log_init(&logger, "watertank");
INFO("Application Started!");
The functions exos_log_error()、exos_log_success() etc. can be rather cumbersome to write, having to pass a pointer to the log handle and specifying the Log Type for every message. Therefore, it is suggested that every application should define its own simplified log macros, for example:
#define INFO(_format_, ...) exos_log_info(&logger, EXOS_LOG_TYPE_USER, _format_, ##__VA_ARGS__);
#define DEBUG(_format_, ...) exos_log_info(&logger, EXOS_LOG_TYPE_USER + EXOS_LOG_TYPE_VERBOSE, _format_, ##__VA_ARGS__);
...
int main(void)
{
exos_log_init(&logger, "watertank");
INFO("Application Started!");
...
...