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 F1904A0547; Fri, 12 Feb 2021 00:27:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B30E322A272; Fri, 12 Feb 2021 00:27:48 +0100 (CET) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 3B46540147 for ; Wed, 10 Feb 2021 04:59:42 +0100 (CET) Received: by mail-pf1-f175.google.com with SMTP id z6so433936pfq.0 for ; Tue, 09 Feb 2021 19:59:42 -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; bh=u9mLInVl5nN7jPYFV5Zxraro97l4zUeyGScc8u5EWLc=; b=HB9kQcijoS+1U4W6R7ZGOD5qPnKmWZohEso/vFcpEZ3Ch7ODzBAa24H5JJqoxtsxvd rNP42ku3wUgxKktJopoQ1gtlCcJ2AVXvA3zZMC4NI46fhmLI+FN6jyvkM5JvgPVuQJtI gprltLdsV18YqCRC9R1rfAHWpIeNyKaWDm+vCtDvanixuZQfZFvjuMpR8l40DqSexy9i SKzc+/Sd/U/jhBei0Us5aHR6t0vTgVHuN0/WGSnpmhocepJof1jkcdjU029eau0qg1gW iEtRZxBcrsKcKfZFWwJwuxkyjrWVN2D3Pqr6SFxQQ90X0hb26eV1q3/vcgYLpzVSAqu3 sReQ== 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; bh=u9mLInVl5nN7jPYFV5Zxraro97l4zUeyGScc8u5EWLc=; b=pK3Ik6fbnWQvaYoxR04gSrN9WVyrdzHWwC9D+Yy4CRWEt5TN0XxXMolJQYdECXLwfk AzV9i/uGpR6hqsXCfERKjNb8D6SiMjCtVxgFKaX0VozS/HxMbOGbGwQaOHuKYKDomiBm O6oAwmFlJYtDM5bKT1H4k60LCLZzR5Yh0XuPJ32WLStxPGD1UWzWMwEDQZ2hwPtuEjrz 1iF4FTFXWwJSrljYpNjHxi9x2dMjJq43avamOB0VSX3xqCjRkc/jvWFsd3rO+YXdcXFA l4/JFow6bi9ExL03LnninRZMjrpZVs2cHJcFbSiIYGqYTvehwAtJ93L2YiyuuNm1Sse9 43eA== X-Gm-Message-State: AOAM5332iFHyZyo/niehvW1wMuupdiCAhxKrMZw72f3zyb/7NsjV7t51 ZumHe3sfsOWfRGexIceJ81QzuauMgjHn0fyi3i4= X-Google-Smtp-Source: ABdhPJy0Y0FSSBcXB3Xadbar8hDwGL34o8J9XZ1JsEVxrnskTygev3E308DFjmgzqmb1hPBf5LruVNqH0TTEwiYSQv0= X-Received: by 2002:a62:7e8c:0:b029:1e1:6431:7ce with SMTP id z134-20020a627e8c0000b02901e1643107cemr1430298pfc.6.1612929581227; Tue, 09 Feb 2021 19:59:41 -0800 (PST) MIME-Version: 1.0 References: <20210205112433.1681853-1-fengli@smartx.com> <20210205174204.1878089-1-fengli@smartx.com> <20210205223207.7fbf82ba@sovereign> <20210209014033.30b55ae2@sovereign> In-Reply-To: <20210209014033.30b55ae2@sovereign> From: Feng Li Date: Wed, 10 Feb 2021 11:59:15 +0800 Message-ID: To: Dmitry Kozlyuk Cc: Li Feng , dev , David Marchand , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Fri, 12 Feb 2021 00:27:47 +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" On Tue, Feb 9, 2021 at 6:40 AM Dmitry Kozlyuk wrote: > > On Mon, 8 Feb 2021 14:58:29 +0800, Feng Li wrote: > > > > +/** > > > > + * Usage function typedef used by the application usage function. > > > > > > It's unrelated to the following typedef purpose, is it? > > It's borrowed from the front typedef sentence. > > Doesn't make much sense here anyway. Acked. > > > > > + * > > > > + * Use this function typedef to define a logger formatter. > > > > + */ > > > > +typedef cookie_write_function_t rte_log_func_t; > > > > > > "cookie_write_function_t" is not standard C, please write this type > > > explicitly. POSIX reserves "_t" suffix, "rte_" prefix is enough. > > Fix to this? > > typedef cookie_write_function_t rte_cookie_write_function; > > You cannot expose "cookie_write_function_t" in public API, because it is not > portable. You have to write out the type in full. > I'd replace "cookie" with "log". Acked. > > > void rte_log_sink_set(rte_cookie_write_function* cookie_write); > > rte_cookie_write_function* rte_log_sink_get(); > > Right? > > OK. > > > > > +void > > > > +rte_eal_set_log_func(rte_log_func_t *logf) > > > > +{ > > > > + console_log_func.write = logf; > > > > +} > > Is this correct? AFAIK, updating the member has no effect, unless you call > fopencookie() with an updated structure. The call order is: rte_eal_set_log_func(logf); ... rte_eal_init(); Because the rte_eal_init will call rte_eal_log_init, so set the struct before rte_eal_init. And the logs in `rte_eal_init` will also be redirected. > > Your new callbacks don't seem to be integrated with DPDK logging system for > all platforms ("eal_common_log.c", "windows/eal_log.c"). If the new API and > rte_openlog_stream() cancel effect of each other, this should be documented. > Looks like `rte_eal_log_init` is defined in Linux and Windows, and Windows only redirects the log to stderr. So Windows doesn't support this feature. rte_openlog_stream has a higher priority than rte_eal_set_log_func. If it isn't called, then 'rte_eal_set_log_func' call will work. I will update the comments of this API. Thanks.