1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <sys/queue.h>
12 #include <rte_memory.h>
14 #include <rte_launch.h>
15 #include <rte_per_lcore.h>
16 #include <rte_lcore.h>
17 #include <rte_spinlock.h>
20 #include "eal_private.h"
23 * default log function
26 console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)
28 char copybuf[BUFSIZ + 1];
33 ret = fwrite(buf, 1, size, stdout);
36 /* truncate message if too big (should not happen) */
40 /* Syslog error levels are from 0 to 7, so subtract 1 to convert */
41 loglevel = rte_log_cur_msg_loglevel() - 1;
42 memcpy(copybuf, buf, size);
45 /* write on syslog too */
46 syslog(loglevel, "%s", copybuf);
51 static cookie_io_functions_t console_log_func = {
52 .write = console_log_write,
56 * set the log to default function, called during eal init process,
57 * once memzones are available.
60 rte_eal_log_init(const char *id, int facility)
64 log_stream = fopencookie(NULL, "w+", console_log_func);
65 if (log_stream == NULL)
68 openlog(id, LOG_NDELAY | LOG_PID, facility);
70 eal_log_set_default(log_stream);