This commit is contained in:
zhanglianghy 2019-08-21 11:04:37 +08:00
commit 3eff7cf13a
5 changed files with 19 additions and 29 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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) {

View File

@ -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);
}

View File

@ -93,7 +93,7 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg
{\
WEBM_HANDLE_CONFIG_ADD_GROUP, \
"/FSG-CF/um-group-add", \
3, \
CM_CONFIG_SET, \
USER_MANAGER_CONFIG_GROUP, \
webm_config_send_proc \
},\
@ -101,7 +101,7 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg
{\
WEBM_HANDLE_CONFIG_IPV4, \
"/ISG-CF/ipv4", \
3, \
CM_CONFIG_SET, \
IPCONFIG_V4, \
webm_config_send_proc \
} \
@ -175,9 +175,11 @@ int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg_id, ch
{
ret = p_d->web_cfg_exec(config_type, confg_id, data_in, strlen(data_in), &mess_str, &mess_len);
}
log_error_write(srv, __FILE__, __LINE__, "s", "ret:", ret);
if (0 != ret)
{
log_error_write(srv, __FILE__, __LINE__, "s", "ret:", ret);
/* create root node and array */
root = cJSON_CreateObject();
@ -205,8 +207,10 @@ int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg_id, ch
}
else
{
log_error_write(srv, __FILE__, __LINE__, "s", "ret:", ret);
buffer_copy_string(data_out, mess_str);
}
log_error_write(srv, __FILE__, __LINE__, "s", "ret:", ret);
ret = 0;
end: