From 0b089674b35a5f4a53bbbdc981a49bfd3a55799e Mon Sep 17 00:00:00 2001 From: "shine.chen" Date: Mon, 4 Nov 2019 18:53:20 -0800 Subject: [PATCH] print log level when dump mclag status Signed-off-by: shine.chen --- src/iccpd/include/logger.h | 1 + src/iccpd/src/iccp_cmd_show.c | 4 ++++ src/iccpd/src/logger.c | 2 +- src/iccpd/src/mclagdctl/mclagdctl.c | 9 +++++---- src/iccpd/src/mclagdctl/mclagdctl.h | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/iccpd/include/logger.h b/src/iccpd/include/logger.h index d21e38d3727d..a90fece2a4d9 100644 --- a/src/iccpd/include/logger.h +++ b/src/iccpd/include/logger.h @@ -59,6 +59,7 @@ struct LoggerConfig struct LoggerConfig* logger_get_configuration(); void logger_set_configuration(int log_level); +char* log_level_to_string(int level); void log_setup(char* progname, char* path); void log_finalize(); void log_init(struct CmdOptionParser* parser); diff --git a/src/iccpd/src/iccp_cmd_show.c b/src/iccpd/src/iccp_cmd_show.c index 5b42de54bbb9..e25a653e74b3 100644 --- a/src/iccpd/src/iccp_cmd_show.c +++ b/src/iccpd/src/iccp_cmd_show.c @@ -40,6 +40,7 @@ int iccp_mclag_config_dump(char * *buf, int *num, int mclag_id) struct CSM *csm = NULL; struct LocalInterface *peer_link_if = NULL; struct LocalInterface *lif_po = NULL; + struct LoggerConfig* logconfig; char unknown[] = { "Unknown" }; int mclag_num = 0; int id_exist = 0; @@ -92,6 +93,9 @@ int iccp_mclag_config_dump(char * *buf, int *num, int mclag_id) if (peer_link_if) memcpy(state_info.peer_link_mac, peer_link_if->mac_addr, 6); + logconfig = logger_get_configuration(); + memcpy(state_info.loglevel, log_level_to_string(logconfig->log_level), strlen( log_level_to_string(logconfig->log_level))); + state_info.role = csm->role_type; str_size = MCLAGDCTL_PORT_MEMBER_BUF_LEN; diff --git a/src/iccpd/src/logger.c b/src/iccpd/src/logger.c index 49c3a11393a8..2c17610f7afc 100644 --- a/src/iccpd/src/logger.c +++ b/src/iccpd/src/logger.c @@ -38,7 +38,7 @@ static uint32_t _iccpd_log_level_map[] = LOG_DEBUG, }; -static char* log_level_to_string(int level) +char* log_level_to_string(int level) { switch (level) { diff --git a/src/iccpd/src/mclagdctl/mclagdctl.c b/src/iccpd/src/mclagdctl/mclagdctl.c index 0396f5fa0a7a..7c5d7284066d 100644 --- a/src/iccpd/src/mclagdctl/mclagdctl.c +++ b/src/iccpd/src/mclagdctl/mclagdctl.c @@ -266,6 +266,7 @@ int mclagdctl_parse_dump_state(char *msg, int data_len) fprintf(stdout, "%s: %s\n", "MCLAG Interface", state_info->enabled_po); + fprintf(stdout, "%s: %s\n", "Loglevel", state_info->loglevel); } return 0; @@ -541,9 +542,9 @@ int mclagdctl_parse_config_loglevel(char *msg, int data_len) int ret = *(int*)msg; if (ret == 0) - fprintf(stdout, "%s\n", "Set mclag config debug level success!"); - else - fprintf(stdout, "%s\n", "Set mclag config debug level failed!"); + fprintf(stdout, "%s\n", "Config loglevel success!"); + else + fprintf(stdout, "%s\n", "Config loglevel failed!"); return 0; } @@ -706,7 +707,7 @@ int main(int argc, char **argv) char *data; struct mclagd_reply_hdr *reply; - while ((opt = getopt_long(argc, argv, "hil:", long_options, NULL)) >= 0) + while ((opt = getopt_long(argc, argv, "hi:l:", long_options, NULL)) >= 0) { switch (opt) { diff --git a/src/iccpd/src/mclagdctl/mclagdctl.h b/src/iccpd/src/mclagdctl/mclagdctl.h index 2c9a24d57ba1..1b8c6f278cc5 100644 --- a/src/iccpd/src/mclagdctl/mclagdctl.h +++ b/src/iccpd/src/mclagdctl/mclagdctl.h @@ -126,6 +126,7 @@ struct mclagd_state unsigned char peer_link_mac[MCLAGDCTL_ETHER_ADDR_LEN]; int role; char enabled_po[MCLAGDCTL_PORT_MEMBER_BUF_LEN]; + char loglevel[MCLAGDCTL_PARA1_LEN]; }; struct mclagd_arp_msg