<< 点击显示目录 >> 主页 exOS使用助手 > exOS Automation Help > Development > Programming > exOS Log API reference (exos_log.h) > exos_log_config_listener(): Listen to configuration changes |
EXOS_ERROR_CODE exos_log_config_listener(exos_log_handle_t *log, exos_config_change_cb config_change_callback, void *user_context);
该函数初始化了一个监听器, 每当收到新配置时,该监听器就会触发一个 exos_config_change_cb 回调。
由于日志记录系统的工作方式是,日志记录器模块要实际记录任何内容,就必须有一个配置,因此这个回调也表示第一次连接到日志记录系统,即日志服务器收到用 exos_log_init()发送的初始化信息 之后。在第一次回调之后,每当系统中的模块通过 exos_log_change_config()发送新的日志配置时,就会触发新的回调 。
虽然大多数信息都可以在 log_handle 中找到,但回调可以简化使用,因为你不必循环检查当前状态。
•log:指向 exos_log_handle_t 的指针
•config_change_callback 收到 新的 exos_log_config_t 时调用的函数(回调) 。其签名通过 exos_config_change_cb进行 定义 。
•user_context:要传递给回调函数的上下文(结构、类等
EXOS_ERROR_CODE exos_log_config_listener(exos_log_handle_t *log, exos_config_change_cb config_change_callback, void *user_context);
This function initializes a listener that triggers an exos_config_change_cb callback whenever a new configuration is received.
As the logging system works in a way that a configuration is necessary for the logger module to actually log anything, this callback also indicates the first time it is connected to the logging system, i.e. after the log server has received the initialization message sent with exos_log_init(). After this first callback, new callbacks are triggered whenever a module in the system broadcasts a new log config via exos_log_change_config().
Wheras most information can be found in the log_handle itself, having a callback simplifies the usage, as you don't have to make cyclic checks of the current status.
•log: pointer to the exos_log_handle_t
•config_change_callback the function (callback) that is called when a new exos_log_config_t has been recieved. The signature is defined via exos_config_change_cb.
•user_context: the context (structure, class etc) that you want to pass on to the callback