diff --git a/Platform/user/logging/cmd_file.c b/Platform/user/logging/cmd_file.c index ac5fb38fc..d5d54734e 100755 --- a/Platform/user/logging/cmd_file.c +++ b/Platform/user/logging/cmd_file.c @@ -6,7 +6,7 @@ #include "s2j/s2j.h" - +void logging_get_file_print(log_file_t *log_file); static int logging_file_json_parse(pointer input, log_file_t *config_buff); @@ -79,12 +79,8 @@ int conf_file(cJSON *json_obj, int argc, char **argv) if (CM_CONFIG_GET == config_type) { logging_file_json_parse(json_output, &log_file_out); - - ULOG_DEBUG(g_log, "Log file get: level=%u, path=%s, is_compress=%d, del_over_days=%u, del_over_size=%s", - log_file_out.level, - log_file_out.path, - log_file_out.is_compress, - log_file_out.del_over_days, log_file_out.del_over_size); + + logging_get_file_print(&log_file_out); } return ret; @@ -128,4 +124,28 @@ static int logging_file_json_parse(pointer input, log_file_t *config_buff) return RET_OK; } +void logging_get_file_print(log_file_t *log_conf) +{ + if (NULL == log_conf) + { + return; + } + + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + fprintf(stdout, " get file:\n\n"); + if (log_conf->level < sizeof(g_level_array) / sizeof(level_str_t)) + fprintf(stdout, " level %s\n", g_level_array[log_conf->level].str); + else + fprintf(stdout, " level \n"); + fprintf(stdout, " file_path %s\n", log_conf->path); + fprintf(stdout, " is_compress %s\n", log_conf->is_compress==LOG_UNCOMPRESS?"no":"yes"); + fprintf(stdout, " del_over_days %u\n", log_conf->del_over_days); + fprintf(stdout, " del_over_size %s\n", log_conf->del_over_size); + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + ULOG_DEBUG(g_log, "Log file get: level=%u, path=%s, is_compress=%d, del_over_days=%u, del_over_size=%s", + log_conf->level, + log_conf->path, + log_conf->is_compress, + log_conf->del_over_days, log_conf->del_over_size); +} diff --git a/Platform/user/logging/cmd_remote.c b/Platform/user/logging/cmd_remote.c index d4ecf602a..f1064e022 100755 --- a/Platform/user/logging/cmd_remote.c +++ b/Platform/user/logging/cmd_remote.c @@ -13,6 +13,8 @@ static int logging_remote_json_parse(pointer input, log_remote_host_x_t *config_ static int logging_remote_json_parse_array(pointer input, log_remote_host_x_t *config_buff, int *cnt); static int logging_remote_level_json_parse(pointer input, log_remote_level_t *config_buff); +static void logging_get_remote_level_print(log_remote_level_t *log_conf); +static void logging_get_remote_print(log_remote_host_x_t *log_conf, uint cnt); static log_rfc_t get_rfc_by_name(const char *name) { @@ -67,15 +69,11 @@ static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16 { if (CM_CONFIG_GET_ALL == config_type ) { - log_remote_host_x_t remotes_out[MAX_REMOTE_HOST_CNT] = {0}; + log_remote_host_x_t remotes_out[MAX_REMOTE_HOST_CNT] = {0}; int cnt = 0; if (logging_remote_json_parse_array(json_output, remotes_out, &cnt) == 0) { - for (int i=0; ilevel < sizeof(g_level_array) / sizeof(level_str_t)) + fprintf(stdout, " level %s\n", g_level_array[log_conf->level].str); + else + fprintf(stdout, " level \n"); + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + + ULOG_DEBUG(g_log, "Log level get: level=%u", log_conf->level); +} + +static void logging_get_remote_print(log_remote_host_x_t *log_conf, uint cnt) +{ + char *tmp_str=NULL; + int i=0; + + if (NULL == log_conf || 0 == cnt) + { + return; + } + + if (1 == cnt) + { + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + fprintf(stdout, " get host:\n\n"); + if (log_conf->level < sizeof(g_level_array) / sizeof(level_str_t)) + tmp_str = &g_level_array[log_conf->level].str; + else + tmp_str = ""; + fprintf(stdout, " level %s\n", tmp_str); + fprintf(stdout, " ip_addr %s\n", log_conf->host); + fprintf(stdout, " port %u\n", log_conf->port); + if (log_conf->rfc < sizeof(rfc_tbl) / sizeof(rfc_key_fmt)) + tmp_str = &rfc_tbl[log_conf->rfc].fmt; + else + tmp_str = ""; + fprintf(stdout, " RFCfmt %s\n", tmp_str); + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + + ULOG_DEBUG(g_log, "Log host get: addr=%s, port=%u, log_fmt=%u, level=%u", + log_conf->host, log_conf->port, log_conf->rfc, log_conf->level); + } + else + { + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + fprintf(stdout, " get hosts:\n\n"); + for (i=0; ilevel < sizeof(g_level_array) / sizeof(level_str_t)) + fprintf(stdout, " level %s\n", g_level_array[conf->level].str); + else + fprintf(stdout, " level \n"); + fprintf(stdout, " on/off %s\n", conf->on==LOG_ON?"on":"off"); + fprintf(stdout, " module %s\n", conf->module); + fprintf(stdout, "--------------------------------------------------------------------------------\n"); + + if (LOG_ON == conf->on) { + ULOG_DEBUG(g_log, "Log %s get: level=%u, module=%s", + (config_id == LOG_CONFIG_CONSOLE)?"console":"monitor", + conf->level, + conf->module); + } else { + ULOG_DEBUG(g_log, "Log %s get: off", + (config_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); + } +} diff --git a/Platform/user/logging/logging_common.h b/Platform/user/logging/logging_common.h index 1054ef0f8..f5901eb95 100755 --- a/Platform/user/logging/logging_common.h +++ b/Platform/user/logging/logging_common.h @@ -15,6 +15,7 @@ extern ulog_t *g_log; 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); +void logging_get_terminal_console_print(void *log_conf, uint64 config_id); #define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \ @@ -47,15 +48,7 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_ \ if (CM_CONFIG_GET == config_type) { \ 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", \ - terminal_out.level, \ - terminal_out.module); \ - } else { \ - ULOG_DEBUG(g_log, "Log %s get: off", \ - (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); \ - } \ + logging_get_terminal_console_print(&terminal_out, conf_id); \ } \ } \ \