if (level > (uint32_t)(rte_log_get_level(logtype)))
return 0;
- rte_hexdump(rte_logs.file == NULL ? stderr : rte_logs.file,
- title, buf, len);
+ rte_hexdump(rte_log_get_stream(), title, buf, len);
return 0;
}
*
* Dump out the message buffer in a special hex dump output format with
* characters printed for each line of 16 hex values. The message will be sent
- * to the stream defined by rte_logs.file or to stderr in case of rte_logs.file
- * is undefined.
+ * to the stream used by the rte_log infrastructure.
*/
int
qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
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)
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;
*/
int rte_openlog_stream(FILE *f);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Retrieve the stream used by the logging system (see rte_openlog_stream()
+ * to change it).
+ *
+ * @return
+ * Pointer to the stream.
+ */
+__rte_experimental
+FILE *rte_log_get_stream(void);
+
/**
* Set the global log level.
*