diff --git a/Common/log_types.h b/Common/log_types.h index d3d0d7b98..276ddb91b 100755 --- a/Common/log_types.h +++ b/Common/log_types.h @@ -8,6 +8,8 @@ #define MAX_LINE_SZ 1024 #define MAX_PATH_SZ MAX_LINE_SZ +#define MAX_U64_SZ 21 + typedef enum { @@ -49,7 +51,7 @@ typedef struct _log_file { char path[MAX_PATH_SZ]; log_compress_t is_compress; u32 del_over_days; - u64 del_over_size; + char del_over_size[MAX_U64_SZ]; } log_file_t; diff --git a/Platform/user/configm/config-server/log_config/log_config_file.c b/Platform/user/configm/config-server/log_config/log_config_file.c index 24211c99f..6b30b5652 100755 --- a/Platform/user/configm/config-server/log_config/log_config_file.c +++ b/Platform/user/configm/config-server/log_config/log_config_file.c @@ -6,7 +6,7 @@ S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, path, MAX_PATH_SZ); \ s2j_struct_get_basic_element(s, o, int, is_compress); \ s2j_struct_get_basic_element(s, o, int, del_over_days); \ - s2j_struct_get_basic_element(s, o, int, del_over_size); \ + S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, del_over_size, MAX_U64_SZ); \ } ret_code log_file_config_chk(uint source, uint *config_type, diff --git a/Platform/user/logging/cmd_file.c b/Platform/user/logging/cmd_file.c index fefae2aba..cfbdc1c34 100755 --- a/Platform/user/logging/cmd_file.c +++ b/Platform/user/logging/cmd_file.c @@ -38,22 +38,19 @@ int conf_file(cJSON *json_obj, int argc, char **argv) return -1; } } - - if (argc >= 7) { - int64_t size = atoll(argv[6]); - if (size > 0) { - log_file.del_over_size = (u64)size; - } else if (size < 0) { - ULOG_WARNING(g_log, "Deleting size(%d) mustn't be less than 0", size); + + if (argc >= 7) { + if (snprintf(log_file.del_over_size, sizeof(log_file.del_over_size), "%s", argv[6]) < 0) { + ULOG_ERR(g_log, "Building del max size:%s is filure", argv[6]); return -1; - } + } } s2j_json_set_basic_element(json_obj, &log_file, int, level); s2j_json_set_basic_element(json_obj, &log_file, string, path); s2j_json_set_basic_element(json_obj, &log_file, int, is_compress); s2j_json_set_basic_element(json_obj, &log_file, int, del_over_days); - s2j_json_set_basic_element(json_obj, &log_file, int, del_over_size); + s2j_json_set_basic_element(json_obj, &log_file, string, del_over_size); int ret = set_log_conf(json_obj, LOG_CONFIG_FILE); if (ret != 0) { diff --git a/Platform/user/ulog/log-sched/log_file.c b/Platform/user/ulog/log-sched/log_file.c index a53ac6d64..b73f231b4 100755 --- a/Platform/user/ulog/log-sched/log_file.c +++ b/Platform/user/ulog/log-sched/log_file.c @@ -124,7 +124,9 @@ static int conf_log_file(const log_file_t *conf) /* 将日志文件大小上限写入本程序配置文件中 */ memset(value_str, 0, sizeof(value_str)); - sprintf(value_str, "%llu", conf->del_over_size); + if (strlen(conf->del_over_size) > 0) { + sprintf(value_str, "%s", conf->del_over_size); + } if (write_log_file_conf(LOG_CONF_KEY_FILE_MAX_SIZE_STR, value_str) != 0) { ULOG_ERR(g_log, "Del-over-size which is written is failure"); return -1; @@ -145,21 +147,6 @@ static int __rpc_conf_log_file(pointer input, const void *arg, char *str_err, in void rpc_conf_log_file(rpc_conn *conn, pointer input, int input_len, pointer data) { - u32 need_len = sizeof(log_file_t); - if (input_len < need_len) { - ULOG_WARNING(g_log, - "The input paramter of rpc log file is needed length of %u, but the actual length is %u", - need_len, input_len); - return; - } - - if (conf_log_file((const log_file_t *)input) != 0) { - ULOG_ERR(g_log, "Configuring file of log is faiure"); - rpc_return_error(conn, RET_ERR, "Configuring file of log is faiure"); - return; - } - rpc_return_null(conn); - rpc_conf_proc(conn, input, input_len, sizeof(log_file_t), __rpc_conf_log_file, NULL); }