From 7a22c7fc29ccea0c9287fc2204d231fe0d2713fc Mon Sep 17 00:00:00 2001 From: liangxia Date: Tue, 27 Aug 2019 16:45:48 +0800 Subject: [PATCH] =?UTF-8?q?Mod=20aaa-12=20=20=E9=9B=86=E4=B8=AD=E6=B6=88?= =?UTF-8?q?=E9=99=A4log=E7=9B=B8=E5=85=B3=E5=B7=A5=E7=A8=8B=E4=B8=AD?= =?UTF-8?q?=E7=9A=84warning=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Aliangxia=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-server/log_config/log_config_cm.c | 2 ++ .../config-server/log_config/log_config_remote.c | 4 ++-- Platform/user/logging/cmd_file.c | 2 +- Platform/user/logging/cmd_remote.c | 4 ++-- Platform/user/logging/logging_common.c | 4 ++-- Platform/user/logging/logging_common.h | 14 +++++++------- Platform/user/ulog/log-sched/log_common.h | 2 +- Platform/user/ulog/log-sched/log_remote.c | 2 +- Platform/user/ulog/log-sched/sev_sched.c | 2 ++ 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Platform/user/configm/config-server/log_config/log_config_cm.c b/Platform/user/configm/config-server/log_config/log_config_cm.c index ca1487e8d..cad81f0d1 100755 --- a/Platform/user/configm/config-server/log_config/log_config_cm.c +++ b/Platform/user/configm/config-server/log_config/log_config_cm.c @@ -4,6 +4,8 @@ #include "rpc_server.h" #include "rpc_client.h" +int access(const char *pathname, int mode); + ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth) { if ((input == NULL) diff --git a/Platform/user/configm/config-server/log_config/log_config_remote.c b/Platform/user/configm/config-server/log_config/log_config_remote.c index e17d859fa..6ca945a44 100755 --- a/Platform/user/configm/config-server/log_config/log_config_remote.c +++ b/Platform/user/configm/config-server/log_config/log_config_remote.c @@ -147,7 +147,7 @@ ret_code log_remote_level_config_getall(uint source, /* *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @1.1.1.1:514:RFC3164fmt * *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @@1.1.1.2:514:RFC5424fmt */ -static ret_code cm_log_prase_host_from_str(const char *input_str, log_remote_host_x_t *ret_host) +static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_host_x_t *ret_host) { char *pos = NULL; char *pos2 = NULL; @@ -336,7 +336,7 @@ static ret_code cm_log_get_host_from_file_by_addr(const char *file_str, const ch while ((getline(&line, &n, fp)) != -1) { memset(tmp_str, 0, sizeof(tmp_str)); - snprintf(tmp_str, "@%s:", addr_str); + sprintf(tmp_str, "@%s:", addr_str); if (NULL == strstr(line, tmp_str)) { continue; diff --git a/Platform/user/logging/cmd_file.c b/Platform/user/logging/cmd_file.c index db879fb1a..ac5fb38fc 100755 --- a/Platform/user/logging/cmd_file.c +++ b/Platform/user/logging/cmd_file.c @@ -16,7 +16,7 @@ int conf_file(cJSON *json_obj, int argc, char **argv) log_file_t log_file_out = {0}; int level = LOG_INFO; uint config_type = CM_CONFIG_SET; - cJSON *json_output = NULL; + char *json_output = NULL; log_file.is_compress = LOG_UNCOMPRESS; diff --git a/Platform/user/logging/cmd_remote.c b/Platform/user/logging/cmd_remote.c index 276ac8c89..d4ecf602a 100755 --- a/Platform/user/logging/cmd_remote.c +++ b/Platform/user/logging/cmd_remote.c @@ -28,7 +28,7 @@ static log_rfc_t get_rfc_by_name(const char *name) static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16 port, const log_rfc_t rfc, uint64 config_id) { log_remote_host_x_t remote = {0}; - cJSON *json_output = NULL; + char *json_output = NULL; int config_type = CM_CONFIG_SET; if (LOG_CONFIG_REMOTE_GET_HOST == config_id) @@ -141,7 +141,7 @@ int conf_remote_level(cJSON *json_obj, int argc, char **argv) log_remote_level_t log_level = {0}; log_remote_level_t log_level_out = {0}; uint config_type = CM_CONFIG_SET; - cJSON *json_output = NULL; + char*json_output = NULL; if (argc < 3) { ULOG_WARNING(g_log, "Not input log level"); diff --git a/Platform/user/logging/logging_common.c b/Platform/user/logging/logging_common.c index 6d5e76183..1dfd8a9bf 100755 --- a/Platform/user/logging/logging_common.c +++ b/Platform/user/logging/logging_common.c @@ -7,7 +7,7 @@ -int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output) +int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output) { int ret = -1; char *output; @@ -48,7 +48,7 @@ int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **js } -int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) +int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id) { cJSON *json_obj = NULL; diff --git a/Platform/user/logging/logging_common.h b/Platform/user/logging/logging_common.h index ea145c606..1054ef0f8 100755 --- a/Platform/user/logging/logging_common.h +++ b/Platform/user/logging/logging_common.h @@ -13,15 +13,15 @@ extern ulog_t *g_log; -int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output); -int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id); +int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output); +int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id); #define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \ type terminal = {0}; \ type terminal_out = {0}; \ int level; \ - cJSON *json_output = NULL; \ + char *json_output = NULL; \ \ if ((level = log_str_to_level(str_level)) < 0) { \ ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \ @@ -49,12 +49,12 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) if (logging_terminal_json_parse(json_output, &terminal_out, conf_id) == 0) { \ if (LOG_ON == terminal_out.on) { \ ULOG_DEBUG(g_log, "Log %s get: level=%u, module=%s", \ - (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor", \ + (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor", \ terminal_out.level, \ - terminal_out.module); \ + terminal_out.module); \ } else { \ ULOG_DEBUG(g_log, "Log %s get: off", \ - (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); \ + (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); \ } \ } \ } \ @@ -64,7 +64,7 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) #define CMD_PARSE_AND_CONFIG_TERMINAL(type, json_obj, argc, argv, conf_id) { \ log_sw_t on = LOG_ON; \ - char *str_level = DEFAULT_LOG_LEVEL; \ + char *str_level = DEFAULT_LOG_LEVEL; \ uint config_type = CM_CONFIG_SET; \ \ if (argc >= 3) { \ diff --git a/Platform/user/ulog/log-sched/log_common.h b/Platform/user/ulog/log-sched/log_common.h index a87e4a0e6..8f92a9cd0 100755 --- a/Platform/user/ulog/log-sched/log_common.h +++ b/Platform/user/ulog/log-sched/log_common.h @@ -15,7 +15,7 @@ #define REDIRECT_SEPERATE " " -typedef int (*rpc_cb)(pointer *input, const void *arg, char *str_err, int str_len); +typedef int (*rpc_cb)(pointer input, const void *arg, char *str_err, int str_len); extern ulog_t *g_log; extern FILE *g_conf_fp; diff --git a/Platform/user/ulog/log-sched/log_remote.c b/Platform/user/ulog/log-sched/log_remote.c index 31da25c7e..b9ceb935a 100755 --- a/Platform/user/ulog/log-sched/log_remote.c +++ b/Platform/user/ulog/log-sched/log_remote.c @@ -347,7 +347,7 @@ static int __rpc_conf_log_remote(pointer input, const void *arg, char *str_err, log_op_t op; memcpy(&op, arg, sizeof(op)); - int ret = config_log_remote_host(op, (const log_remote_level_t *)input); + int ret = config_log_remote_host(op, (const log_remote_host_t *)input); if (ret < 0) { strncpy(str_err, "Configuring remote of log is faiure", str_len); } diff --git a/Platform/user/ulog/log-sched/sev_sched.c b/Platform/user/ulog/log-sched/sev_sched.c index 6847553c6..63db2589d 100755 --- a/Platform/user/ulog/log-sched/sev_sched.c +++ b/Platform/user/ulog/log-sched/sev_sched.c @@ -5,6 +5,8 @@ #include "log_common.h" #include "ulog_api.h" +#include + #define SEV_TIMEOUT 1 #define SEV_CMD "systemctl restart rsyslog"