From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [PATCH 01/11] avp: implement dynamic logging Date: Fri, 22 Dec 2017 14:45:41 +0100 Message-ID: <20171222134540.d2bhumpw63apdvkd@platinum> References: <20171219063840.18981-1-stephen@networkplumber.org> <20171219063840.18981-2-stephen@networkplumber.org> <6170a4ed-87ff-c750-f3f3-a38e192e6698@intel.com> <20171220105804.5ac92c42@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Stephen Hemminger , dev@dpdk.org To: Ferruh Yigit Return-path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 62F281B36E for ; Fri, 22 Dec 2017 14:45:49 +0100 (CET) Content-Disposition: inline In-Reply-To: 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 Thu, Dec 21, 2017 at 10:02:14AM -0800, Ferruh Yigit wrote: > On 12/20/2017 10:58 AM, Stephen Hemminger wrote: > >> [1] something like: > >> #define INIT_LOG_VAR_NAME(pmd, type) logtype_ ## pmd ## _ ## type > >> #define INIT_LOG_FUNC_NAME(pmd, type) log_ ## pmd ## _ ## type > >> > >> #define PMD_INIT_LOG(pmd, type, level) \ > >> int INIT_LOG_VAR_NAME(pmd, type); \ > >> RTE_INIT(INIT_LOG_FUNC_NAME(pmd, type)); \ > >> static void INIT_LOG_FUNC_NAME(pmd, type)(void) \ > >> { \ > >> INIT_LOG_VAR_NAME(pmd, type) = rte_log_register("pmd." > >> RTE_STR(pmd) "." RTE_STR(type)); \ > >> if (INIT_LOG_VAR_NAME(pmd, type) > 0) \ > >> rte_log_set_level(INIT_LOG_VAR_NAME(pmd, type), > >> RTE_LOG_##level); \ > >> } > > > > That macro is a little complex. Also, for better or worse, the current > > logging is done on a per driver basis. If we want to do something fancier > > it should be in common EAL core. > > Of course, my intention was putting it into rte_log.h so updates in each driver > will be minimal. But this can be done better to cover library updates as well. It's a good idea. Below is another proposition (untested) that panics if rte_log_register() fails, and that defines a static variable with a predefined name. #define RTE_LOG_TYPE_REGISTER(name, level) \ static int name##_log_type; \ __attribute__((constructor, used)) \ static void rte_log_register_##name(void) \ { \ name##_log_type = rte_log_register(#name); \ RTE_VERIFY(name##_log_type >= 0); \ rte_log_set_level(name##_log_type, level); \ }