From c48aebce8da551d8d720322c1f69dcf60df3cff0 Mon Sep 17 00:00:00 2001 From: liyuxi Date: Fri, 19 May 2023 05:44:58 +0000 Subject: [PATCH] chore(file plugin):update log level --- plugins/file/file_plugin.c | 26 +++++++++++++++++++++----- plugins/file/file_req.c | 6 +++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/file/file_plugin.c b/plugins/file/file_plugin.c index b7989b16..02820519 100644 --- a/plugins/file/file_plugin.c +++ b/plugins/file/file_plugin.c @@ -74,6 +74,9 @@ static neu_plugin_t *driver_open(void) static int driver_close(neu_plugin_t *plugin) { + plog_notice(plugin, "close and free `%s` plugin success", + plugin->common.name); + free(plugin); return 0; @@ -83,13 +86,17 @@ static int driver_init(neu_plugin_t *plugin) { plugin->events = neu_event_new(); + plog_notice(plugin, "initialize `%s` plugin success", plugin->common.name); + return 0; } static int driver_uninit(neu_plugin_t *plugin) { neu_event_close(plugin->events); - plog_info(plugin, "node; file uininit ok"); + + plog_notice(plugin, "uninitialize `%s` plugin success", + plugin->common.name); return 0; } @@ -98,6 +105,8 @@ static int driver_start(neu_plugin_t *plugin) { plugin->common.link_state = NEU_NODE_LINK_STATE_CONNECTED; + plog_notice(plugin, "start `%s` plugin success", plugin->common.name); + return 0; } @@ -105,6 +114,8 @@ static int driver_stop(neu_plugin_t *plugin) { plugin->common.link_state = NEU_NODE_LINK_STATE_DISCONNECTED; + plog_notice(plugin, "stop `%s` plugin success", plugin->common.name); + return 0; } @@ -115,7 +126,7 @@ static int driver_config(neu_plugin_t *plugin, const char *config) int ret = neu_parse_param((char *) config, &err_param, 1, &file_length); if (ret != 0) { - plog_warn(plugin, "config:%s, decode error: %s", config, err_param); + plog_error(plugin, "config:%s, decode error: %s", config, err_param); free(err_param); return -1; } @@ -138,8 +149,8 @@ static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head, static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag) { - plog_debug(plugin, "validate tag success, name:%s, address:%s,type:%d ", - tag->name, tag->address, tag->type); + plog_notice(plugin, "validate tag success, name:%s, address:%s, type:%d ", + tag->name, tag->address, tag->type); return 0; } @@ -152,5 +163,10 @@ static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group) static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag, neu_value_u value) { - return file_write(plugin, req, tag, value); + int ret = file_write(plugin, req, tag, value); + + plog_notice(plugin, "write response, ret: %d, tag_name: %s, type: %d", ret, + tag->name, tag->type); + + return ret; } diff --git a/plugins/file/file_req.c b/plugins/file/file_req.c index c0eb08b8..b3a4ed65 100644 --- a/plugins/file/file_req.c +++ b/plugins/file/file_req.c @@ -62,7 +62,7 @@ int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group) } if ((f = fopen(tag->address, "rb+")) == NULL) { - nlog_error("open file:%s", tag->address); + nlog_warn("open file:%s", tag->address); dvalue.type = NEU_TYPE_ERROR; dvalue.value.i32 = NEU_ERR_FILE_OPEN_FAILURE; goto dvalue_result; @@ -81,7 +81,7 @@ int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group) fseek(f, 0, SEEK_SET); int ret = fread(buf, sizeof(char), length, f); if (ret == 0) { - nlog_error("read file failed:%s", tag->address); + nlog_warn("read file failed:%s", tag->address); dvalue.type = NEU_TYPE_ERROR; dvalue.value.i32 = NEU_ERR_FILE_READ_FAILURE; @@ -125,7 +125,7 @@ int file_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag, int ret = 0; if (0 == fwrite(value.str, sizeof(char), strlen(value.str), fp)) { - nlog_error("write file failed:%s", tag->address); + nlog_warn("write file failed:%s", tag->address); ret = NEU_ERR_FILE_WRITE_FAILURE; goto dvalue_result; }