X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_log.c;h=c0efd5214fa99914f02f75044d78d160c77980fd;hb=5aa2f0db4acf256d1655fa12c3e868b77f6f52ee;hp=818118944a72a00c4acaedf84b9612398fb0e2fb;hpb=6ff0f81d0ef79acc2544de6a1b52037cd9864395;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 818118944a..c0efd5214f 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -45,7 +45,7 @@ static struct rte_eal_opt_loglevel_list opt_loglevel_list = static FILE *default_log_stream; /** - * This global structure stores some informations about the message + * This global structure stores some information about the message * that is currently being processed by one lcore */ struct log_cur_msg { @@ -71,6 +71,24 @@ rte_openlog_stream(FILE *f) return 0; } +FILE * +rte_log_get_stream(void) +{ + FILE *f = rte_logs.file; + + if (f == NULL) { + /* + * Grab the current value of stderr here, rather than + * just initializing default_log_stream to stderr. This + * ensures that we will always use the current value + * of stderr, even if the application closes and + * reopens it. + */ + return default_log_stream ? : stderr; + } + return f; +} + /* Set global log level */ void rte_log_set_global_level(uint32_t level) @@ -268,7 +286,7 @@ rte_log_register(const char *name) } /* Register an extended log type and try to pick its level from EAL options */ -int __rte_experimental +int rte_log_register_type_and_pick_level(const char *name, uint32_t level_def) { struct rte_eal_opt_loglevel *opt_ll; @@ -335,9 +353,7 @@ static const struct logtype logtype_strings[] = { }; /* Logging should be first initializer (before drivers and bus) */ -RTE_INIT_PRIO(rte_log_init, LOG); -static void -rte_log_init(void) +RTE_INIT_PRIO(rte_log_init, LOG) { uint32_t i; @@ -398,21 +414,8 @@ rte_log_dump(FILE *f) int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) { + FILE *f = rte_log_get_stream(); int ret; - FILE *f = rte_logs.file; - if (f == NULL) { - f = default_log_stream; - if (f == NULL) { - /* - * Grab the current value of stderr here, rather than - * just initializing default_log_stream to stderr. This - * ensures that we will always use the current value - * of stderr, even if the application closes and - * reopens it. - */ - f = stderr; - } - } if (level > rte_logs.level) return 0;