parent
b2c48c629a
commit
dea73514aa
|
@ -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 <invalid_value>\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);
|
||||
}
|
||||
|
|
|
@ -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; i<cnt; i++)
|
||||
{
|
||||
ULOG_DEBUG(g_log, "Log host get: host[%d]: addr=%s, port=%u, log_fmt=%u, level=%u",
|
||||
i, remotes_out[i].host, remotes_out[i].port, remotes_out[i].rfc, remotes_out[i].level);
|
||||
}
|
||||
logging_get_remote_print(remotes_out, cnt);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -83,8 +81,7 @@ static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16
|
|||
log_remote_host_x_t remote_out = {0};
|
||||
if (logging_remote_json_parse(json_output, &remote_out) == 0)
|
||||
{
|
||||
ULOG_DEBUG(g_log, "Log host get: addr=%s, port=%u, log_fmt=%u, level=%u",
|
||||
remote_out.host, remote_out.port, remote_out.rfc, remote_out.level);
|
||||
logging_get_remote_print(&remote_out, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +169,8 @@ int conf_remote_level(cJSON *json_obj, int argc, char **argv)
|
|||
|
||||
if (CM_CONFIG_GET == config_type) {
|
||||
logging_remote_level_json_parse(json_output, &log_level_out);
|
||||
|
||||
ULOG_DEBUG(g_log, "Log level get: level=%u", log_level_out.level);
|
||||
|
||||
logging_get_remote_level_print(&log_level_out);
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
@ -311,4 +308,85 @@ static int logging_remote_level_json_parse(pointer input, log_remote_level_t *co
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void logging_get_remote_level_print(log_remote_level_t *log_conf)
|
||||
{
|
||||
if (NULL == log_conf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stdout, "--------------------------------------------------------------------------------\n");
|
||||
fprintf(stdout, " get trap:\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 <invalid_value>\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 = "<invalid_value>";
|
||||
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 = "<invalid_value>";
|
||||
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; i<cnt; i++)
|
||||
{
|
||||
fprintf(stdout, " host[%d]:\n", i);
|
||||
if (log_conf[i].level < sizeof(g_level_array) / sizeof(level_str_t))
|
||||
tmp_str = &g_level_array[log_conf[i].level].str;
|
||||
else
|
||||
tmp_str = "<invalid_value>";
|
||||
fprintf(stdout, " level %s\n", tmp_str);
|
||||
fprintf(stdout, " ip_addr %s\n", log_conf[i].host);
|
||||
fprintf(stdout, " port %u\n", log_conf[i].port);
|
||||
if (log_conf[i].rfc < sizeof(rfc_tbl) / sizeof(rfc_key_fmt))
|
||||
tmp_str = &rfc_tbl[log_conf[i].rfc].fmt;
|
||||
else
|
||||
tmp_str = "<invalid_value>";
|
||||
fprintf(stdout, " RFCfmt %s\n", tmp_str);
|
||||
}
|
||||
fprintf(stdout, "--------------------------------------------------------------------------------\n");
|
||||
|
||||
for (i=0; i<cnt; i++)
|
||||
{
|
||||
ULOG_DEBUG(g_log, "Log host get: host[%d]: addr=%s, port=%u, log_fmt=%u, level=%u",
|
||||
i, log_conf[i].host, log_conf[i].port, log_conf[i].rfc, log_conf[i].level);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -79,5 +79,34 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_
|
|||
cJSON_Delete(json_obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void logging_get_terminal_console_print(void *log_conf, uint64 config_id)
|
||||
{
|
||||
log_console_t *conf = log_conf;
|
||||
if (NULL == conf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stdout, "--------------------------------------------------------------------------------\n");
|
||||
fprintf(stdout, " get %s:\n\n", config_id==LOG_CONFIG_CONSOLE?"console":"terminal");
|
||||
if (conf->level < sizeof(g_level_array) / sizeof(level_str_t))
|
||||
fprintf(stdout, " level %s\n", g_level_array[conf->level].str);
|
||||
else
|
||||
fprintf(stdout, " level <invalid_value>\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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
|
|
Loading…
Reference in New Issue