From: John Ousterhout <ouster@cs.stanford.edu>
To: david.marchand@6wind.com
Cc: dev@dpdk.org, John Ousterhout <ouster@cs.stanford.edu>
Subject: [dpdk-dev] [PATCH] log: respect rte_openlog_stream calls before rte_eal_init
Date: Wed, 28 Sep 2016 13:42:44 -0700 [thread overview]
Message-ID: <20160928204244.8288-1-ouster@cs.stanford.edu> (raw)
Before this patch, rte_eal_init invoked rte_openlog_stream, cancelling
any application-specific logger and making it it impossible for an
application to capture the initial log messages generated during
rte_eal_init. With this patch, applications can capture all of the
log messages.
Signed-off-by: John Ousterhout <ouster@cs.stanford.edu>
---
lib/librte_eal/bsdapp/eal/eal_log.c | 3 +--
lib/librte_eal/common/eal_common_log.c | 13 +++++++------
lib/librte_eal/common/include/rte_log.h | 2 +-
lib/librte_eal/linuxapp/eal/eal_log.c | 3 +--
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/lib/librte_eal/bsdapp/eal/eal_log.c b/lib/librte_eal/bsdapp/eal/eal_log.c
index a425f7a..c5b1dee 100644
--- a/lib/librte_eal/bsdapp/eal/eal_log.c
+++ b/lib/librte_eal/bsdapp/eal/eal_log.c
@@ -52,6 +52,5 @@ rte_eal_log_init(const char *id __rte_unused, int facility __rte_unused)
int
rte_eal_log_early_init(void)
{
- rte_openlog_stream(stderr);
- return 0;
+ return rte_eal_common_log_init(stderr);
}
diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index 967991a..cfc4c8b 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -48,11 +48,12 @@ struct rte_logs rte_logs = {
.file = NULL,
};
+/* Stream to use for logging if rte_logs.file is NULL */
static FILE *default_log_stream;
/**
* This global structure stores some informations about the message
- * that is currently beeing processed by one lcore
+ * that is currently being processed by one lcore
*/
struct log_cur_msg {
uint32_t loglevel; /**< log level - see rte_log.h */
@@ -68,10 +69,7 @@ static RTE_DEFINE_PER_LCORE(struct log_cur_msg, log_cur_msg);
int
rte_openlog_stream(FILE *f)
{
- if (f == NULL)
- rte_logs.file = default_log_stream;
- else
- rte_logs.file = f;
+ rte_logs.file = f;
return 0;
}
@@ -127,6 +125,8 @@ rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
{
int ret;
FILE *f = rte_logs.file;
+ if (f == NULL)
+ f = default_log_stream;
if ((level > rte_logs.level) || !(logtype & rte_logs.type))
return 0;
@@ -158,7 +158,8 @@ rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
}
/*
- * called by environment-specific log init function
+ * Called during initialization to specify where to log messages if
+ * openlog_stream hasn't been called.
*/
int
rte_eal_common_log_init(FILE *default_log)
diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
index 919563c..d99baf3 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -54,7 +54,7 @@ extern "C" {
struct rte_logs {
uint32_t type; /**< Bitfield with enabled logs. */
uint32_t level; /**< Log level. */
- FILE *file; /**< Pointer to current FILE* for logs. */
+ FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */
};
/** Global log informations */
diff --git a/lib/librte_eal/linuxapp/eal/eal_log.c b/lib/librte_eal/linuxapp/eal/eal_log.c
index d391100..aafc41c 100644
--- a/lib/librte_eal/linuxapp/eal/eal_log.c
+++ b/lib/librte_eal/linuxapp/eal/eal_log.c
@@ -136,6 +136,5 @@ rte_eal_log_early_init(void)
printf("Cannot configure early_log_stream\n");
return -1;
}
- rte_openlog_stream(early_log_stream);
- return 0;
+ return rte_eal_common_log_init(early_log_stream);
}
--
2.8.3
next reply other threads:[~2016-09-28 20:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 20:42 John Ousterhout [this message]
2016-09-30 15:01 ` Thomas Monjalon
2016-10-10 22:39 ` [dpdk-dev] [PATCH v2] " John Ousterhout
2016-10-11 8:08 ` Thomas Monjalon
2016-10-11 16:30 ` John Ousterhout
2016-10-11 20:30 ` Thomas Monjalon
2016-10-11 21:46 ` John Ousterhout
2016-10-12 7:09 ` Thomas Monjalon
2016-10-11 22:16 ` Don Provan
2016-10-12 0:22 ` John Ousterhout
2016-10-12 19:29 ` [dpdk-dev] [PATCH v3] " John Ousterhout
2016-10-12 19:38 ` [dpdk-dev] [PATCH v4] " John Ousterhout
2016-10-12 19:47 ` Thomas Monjalon
2016-10-12 21:17 ` John Ousterhout
2016-10-13 20:03 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160928204244.8288-1-ouster@cs.stanford.edu \
--to=ouster@cs.stanford.edu \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).