From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id B5D1A376F for ; Tue, 4 Apr 2017 18:44:47 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 091302565B; Tue, 4 Apr 2017 18:44:42 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: david.marchand@6wind.com, bruce.richardson@intel.com, thomas.monjalon@6wind.com, keith.wiles@intel.com, stephen@networkplumber.org Date: Tue, 4 Apr 2017 18:40:34 +0200 Message-Id: <20170404164040.24132-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170404164040.24132-1-olivier.matz@6wind.com> References: <20170329155323.4760-1-olivier.matz@6wind.com> <20170404164040.24132-1-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v3 2/8] eal: dump registered log types X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Apr 2017 16:44:48 -0000 Introduce a function to dump the global level and the registered log types. Signed-off-by: Olivier Matz --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_log.c | 34 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_log.h | 10 ++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 46 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index df859666d..bd63ea66b 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -186,6 +186,7 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_log_dump; rte_log_register; rte_log_set_level; diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 68d879ae2..90326215b 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -243,6 +243,40 @@ rte_log_init(void) rte_logs.dynamic_types_len = RTE_LOGTYPE_FIRST_EXT_ID; } +static const char * +loglevel_to_string(uint32_t level) +{ + switch (level) { + case RTE_LOG_EMERG: return "emerg"; + case RTE_LOG_ALERT: return "alert"; + case RTE_LOG_CRIT: return "critical"; + case RTE_LOG_ERR: return "error"; + case RTE_LOG_WARNING: return "warning"; + case RTE_LOG_NOTICE: return "notice"; + case RTE_LOG_INFO: return "info"; + case RTE_LOG_DEBUG: return "debug"; + default: return "unknown"; + } +} + +/* dump global level and registered log types */ +void +rte_log_dump(FILE *f) +{ + size_t i; + + fprintf(f, "global log level is %s\n", + loglevel_to_string(rte_get_log_level())); + + for (i = 0; i < rte_logs.dynamic_types_len; i++) { + if (rte_logs.dynamic_types[i].name == NULL) + continue; + fprintf(f, "id %zu: %s, level is %s\n", + i, rte_logs.dynamic_types[i].name, + loglevel_to_string(rte_logs.dynamic_types[i].loglevel)); + } +} + /* * Generates a log message The message will be sent in the stream * defined by the previous call to rte_openlog_stream(). diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h index e71887fca..97e0c5e52 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -209,6 +209,16 @@ int rte_log_cur_msg_logtype(void); int rte_log_register(const char *name); /** + * Dump log information. + * + * Dump the global level and the registered log types. + * + * @param f + * The output stream where the dump should be sent. + */ +void rte_log_dump(FILE *f); + +/** * Generates a log message. * * The message will be sent in the stream defined by the previous call diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index f75f52efb..ef48500e9 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -190,6 +190,7 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_log_dump; rte_log_register; rte_log_set_level; -- 2.11.0