* [dpdk-dev] [PATCH] eal: fix log level check
@ 2015-04-06 19:14 David Marchand
2015-04-28 13:46 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: David Marchand @ 2015-04-06 19:14 UTC (permalink / raw)
To: dev
From: Jean Dao <jean.dao@6wind.com>
According to the api, rte_log() / rte_vlog() are supposed to check the log level
and type but they were not doing so. This check was only done in the RTE_LOG
macro while this macro is only there to remove log messages at build time.
rte_log() always calls rte_vlog(), so move the check to rte_vlog() only.
Signed-off-by: Jean Dao <jean.dao@6wind.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_eal/common/eal_common_log.c | 8 +++++---
lib/librte_eal/common/include/rte_log.h | 4 +---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index ff44d23..fe3d7d5 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -265,14 +265,15 @@ rte_log_dump_history(FILE *out)
* defined by the previous call to rte_openlog_stream().
*/
int
-rte_vlog(__attribute__((unused)) uint32_t level,
- __attribute__((unused)) uint32_t logtype,
- const char *format, va_list ap)
+rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
{
int ret;
FILE *f = rte_logs.file;
unsigned lcore_id;
+ if ((level > rte_logs.level) || !(logtype & rte_logs.type))
+ return 0;
+
/* save loglevel and logtype in a global per-lcore variable */
lcore_id = rte_lcore_id();
if (lcore_id < RTE_MAX_LCORE) {
@@ -288,6 +289,7 @@ rte_vlog(__attribute__((unused)) uint32_t level,
/*
* Generates a log message The message will be sent in the stream
* defined by the previous call to rte_openlog_stream().
+ * No need to check level here, done by rte_vlog().
*/
int
rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
index f83a0d9..3b467c1 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -299,9 +299,7 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
* - Negative on error.
*/
#define RTE_LOG(l, t, ...) \
- (void)(((RTE_LOG_ ## l <= RTE_LOG_LEVEL) && \
- (RTE_LOG_ ## l <= rte_logs.level) && \
- (RTE_LOGTYPE_ ## t & rte_logs.type)) ? \
+ (void)((RTE_LOG_ ## l <= RTE_LOG_LEVEL) ? \
rte_log(RTE_LOG_ ## l, \
RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \
0)
--
1.7.10.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: fix log level check
2015-04-06 19:14 [dpdk-dev] [PATCH] eal: fix log level check David Marchand
@ 2015-04-28 13:46 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2015-04-28 13:46 UTC (permalink / raw)
To: Jean Dao; +Cc: dev
> According to the api, rte_log() / rte_vlog() are supposed to check the log level
> and type but they were not doing so. This check was only done in the RTE_LOG
> macro while this macro is only there to remove log messages at build time.
>
> rte_log() always calls rte_vlog(), so move the check to rte_vlog() only.
>
> Signed-off-by: Jean Dao <jean.dao@6wind.com>
> Signed-off-by: David Marchand <david.marchand@6wind.com>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-28 13:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 19:14 [dpdk-dev] [PATCH] eal: fix log level check David Marchand
2015-04-28 13:46 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).