From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from lfbn-lil-1-110-231.w90-45.abo.wanadoo.fr ([90.45.197.231] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eSNkA-0006aW-GE; Fri, 22 Dec 2017 14:52:11 +0100 Received: by droids-corp.org (sSMTP sendmail emulation); Fri, 22 Dec 2017 14:45:41 +0100 Date: Fri, 22 Dec 2017 14:45:41 +0100 From: Olivier MATZ To: Ferruh Yigit Cc: Stephen Hemminger , dev@dpdk.org 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 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH 01/11] avp: implement dynamic logging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Dec 2017 13:45:49 -0000 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); \ }