Add aaa-12 modify del_over size to string
RCA: SOL: 修改人:zhangtao 检视人:
This commit is contained in:
parent
496451c9c9
commit
ed7c49f4c1
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#define MAX_LINE_SZ 1024
|
#define MAX_LINE_SZ 1024
|
||||||
#define MAX_PATH_SZ MAX_LINE_SZ
|
#define MAX_PATH_SZ MAX_LINE_SZ
|
||||||
|
#define MAX_U64_SZ 21
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -49,7 +51,7 @@ typedef struct _log_file {
|
||||||
char path[MAX_PATH_SZ];
|
char path[MAX_PATH_SZ];
|
||||||
log_compress_t is_compress;
|
log_compress_t is_compress;
|
||||||
u32 del_over_days;
|
u32 del_over_days;
|
||||||
u64 del_over_size;
|
char del_over_size[MAX_U64_SZ];
|
||||||
} log_file_t;
|
} log_file_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, path, MAX_PATH_SZ); \
|
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, is_compress); \
|
||||||
s2j_struct_get_basic_element(s, o, int, del_over_days); \
|
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,
|
ret_code log_file_config_chk(uint source, uint *config_type,
|
||||||
|
|
|
@ -38,22 +38,19 @@ int conf_file(cJSON *json_obj, int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 7) {
|
if (argc >= 7) {
|
||||||
int64_t size = atoll(argv[6]);
|
if (snprintf(log_file.del_over_size, sizeof(log_file.del_over_size), "%s", argv[6]) < 0) {
|
||||||
if (size > 0) {
|
ULOG_ERR(g_log, "Building del max size:%s is filure", argv[6]);
|
||||||
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);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s2j_json_set_basic_element(json_obj, &log_file, int, level);
|
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, string, path);
|
||||||
s2j_json_set_basic_element(json_obj, &log_file, int, is_compress);
|
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_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);
|
int ret = set_log_conf(json_obj, LOG_CONFIG_FILE);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
|
@ -124,7 +124,9 @@ static int conf_log_file(const log_file_t *conf)
|
||||||
|
|
||||||
/* 将日志文件大小上限写入本程序配置文件中 */
|
/* 将日志文件大小上限写入本程序配置文件中 */
|
||||||
memset(value_str, 0, sizeof(value_str));
|
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) {
|
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");
|
ULOG_ERR(g_log, "Del-over-size which is written is failure");
|
||||||
return -1;
|
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)
|
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);
|
rpc_conf_proc(conn, input, input_len, sizeof(log_file_t), __rpc_conf_log_file, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue