From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B290CA0547; Sun, 7 Feb 2021 10:38:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D94391606D7; Sun, 7 Feb 2021 10:38:40 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 825E940682 for ; Fri, 5 Feb 2021 18:47:35 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id q72so4036404pjq.2 for ; Fri, 05 Feb 2021 09:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=L/Jq0yLf3h5us5NcTwE5WZa9m12tD7KQwcLVfn4Pxfo=; b=iiICrz7CfgfI/khNEWdL1QK+v78QJ43DQB6BC7Dv8mKGDQJ++VKiOHDmO6GY542fqw upLG0tKNb8XUHB0KwIvppvOug+lKPTyXZGOqJdwPijyo+/ocGOuafPozX4WpLW0v3koZ d7tMafF6u6XUl2diL3MC6rJwbtqxrYImlzXmsZN0MQpPV3HluPS2d1tP9vNESwz2kZxP 6zP8OvlowrcZUpd8avZgJxuG2cNVRs206HxgPD+RR1hbIIZgKvYWjh0qGjtkUWVvaH79 2PiFywgriewVEvHA70mel/IXDorE+YHPwgb4OZxVOQuiCAz1gdDqu0ztA9fR/wA/aO99 Ev/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=L/Jq0yLf3h5us5NcTwE5WZa9m12tD7KQwcLVfn4Pxfo=; b=q9iE0spW4et8vIEALqmgcryabKI7pR83j5gi2bYnxT5JD61ojoHHp92K3WWU6kLgF9 MJ8pqybHtETtcelneFsnMQhRirVw1jr1xB2Mwk6NiqT37WWrYv3kxZVpKvHwuI/gXtUE Y1UknOUCWmm0DeR4JXXxCPQmsS4mXtL3wsb8rgmDXJFhdo8NeV2Ikty9kfJ0OoUK6rW+ aqSViM+suZKtJB+W55HwPLHRh7aqfO1//KF3wL9MQI8nuTFM1luP+UPqtfCJv+mHDdbt TJjnzBv8VDlbg2mYt4D/1bhyFM+rwD/3E6mby0YeDsA4GexlgZXcpizJsVI4GetzmVhS H2Ng== X-Gm-Message-State: AOAM530iyn9bOIGfPUTRy7Q4mgwa3lupf1tn6c9HJKu1jranTXPgAW5u /yaPw0DM6kBQfvPnFKhZn9DOwl5IuBbKIEIBiX8= X-Google-Smtp-Source: ABdhPJxQJRY8HOYL4+55hSQGsf0t+FPgdDUg/+EeDqTJN1hHwkBkDn9pKhF+16S4E+Lh2IM/kuTy0kn8k1Qi0dJWjCc= X-Received: by 2002:a17:90a:ba0b:: with SMTP id s11mr5274525pjr.182.1612547254720; Fri, 05 Feb 2021 09:47:34 -0800 (PST) MIME-Version: 1.0 References: <20210205112433.1681853-1-fengli@smartx.com> <20210205174204.1878089-1-fengli@smartx.com> In-Reply-To: <20210205174204.1878089-1-fengli@smartx.com> From: Feng Li Date: Sat, 6 Feb 2021 01:47:08 +0800 Message-ID: To: Li Feng , David Marchand , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Sun, 07 Feb 2021 10:38:37 +0100 Subject: Re: [dpdk-dev] [PATCH v2] log: support custom log function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Li Feng =E4=BA=8E2021=E5=B9=B42=E6=9C=886=E6=97=A5=E5= =91=A8=E5=85=AD =E4=B8=8A=E5=8D=881:42=E5=86=99=E9=81=93=EF=BC=9A > > Currently, the dpdk log is out to stdout/stderr and syslog. > The rte_openlog_stream could set an external FILE* stream, but it asks th= e > consumer to give it a FILE* pointer. > For C++ or other languages, it's hard to get a libc FILE*. > > Support to set a hook method is another choice for this scenario. > > Change-Id: I3b2419cc2fe5256205daa8077fd8862a8e58fb6c > Signed-off-by: Li Feng > --- > v2: simplify the code. > > lib/librte_eal/include/rte_eal.h | 16 ++++++++++++++++ > lib/librte_eal/linux/eal_log.c | 10 ++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/lib/librte_eal/include/rte_eal.h b/lib/librte_eal/include/rt= e_eal.h > index eaf6469e5..bd6cf554b 100644 > --- a/lib/librte_eal/include/rte_eal.h > +++ b/lib/librte_eal/include/rte_eal.h > @@ -501,6 +501,22 @@ rte_eal_mbuf_user_pool_ops(void); > const char * > rte_eal_get_runtime_dir(void); > > +/** > + * Usage function typedef used by the application usage function. > + * > + * Use this function typedef to define a logger formatter. > + */ > +typedef cookie_write_function_t rte_log_func_t; > + > +/** > + * Set a customized logger. > + * > + * @param logf > + * The customized logger function. > + */ > +void > +rte_eal_set_log_func(rte_log_func_t *logf); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_eal/linux/eal_log.c b/lib/librte_eal/linux/eal_lo= g.c > index 43c8460bf..c0a7a12ab 100644 > --- a/lib/librte_eal/linux/eal_log.c > +++ b/lib/librte_eal/linux/eal_log.c > @@ -60,3 +60,13 @@ rte_eal_log_init(const char *id, int facility) > > return 0; > } > + > +/* > + * Set the customized logger, it will override the default action, which= is > + * writing to syslog and stdout. > + */ > +void > +rte_eal_set_log_func(rte_log_func_t *logf) > +{ > + console_log_func.write =3D logf; > +} > -- > 2.29.2 > Add more CCers.