[dpdk-dev] [PATCH] log: support custom log function

Feng Li lifeng1519 at gmail.com
Fri Feb 5 18:06:10 CET 2021


Feng Li <lifeng1519 at gmail.com> 于2021年2月6日周六 上午12:54写道:
>
> Stephen Hemminger <stephen at networkplumber.org> 于2021年2月6日周六 上午12:11写道:
> >
> > On Fri, 5 Feb 2021 12:55:48 +0100
> > David Marchand <david.marchand at redhat.com> wrote:
> >
> > > On Fri, Feb 5, 2021 at 12:25 PM Li Feng <fengli at smartx.com> wrote:
> > > >
> > > > Currently, the dpdk log is out to stdout/stderr and syslog.
> > > > We should support to output the log to another please, e.g. file or
> > > > glog.
> > >
> > > Why not use rte_openlog_stream() / rte_log_get_stream() ?
> >
> > Agree, I have used rte_openlog_stream several times to do this.
> As Dmitry Kozlyuk said, FILE* is convenient for the C/libc, but not
> for other languages.
> C++ standard IO stream is the case.

The usage is like this:
| +static ssize_t eal_log_func(void* c, const char* buf, size_t size) {
| +    int glog_level = google::GLOG_INFO;
| +    (void)c;
| +    google::LogMessage(__FILE__, __LINE__, glog_level).stream()
| +        << "[DPDK/" << __FUNCTION__ << "] " << std::string(buf, size);
| +    return 0;
| +}


More information about the dev mailing list