From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 07CFE469710 for ; Thu, 28 May 2020 20:34:26 +0300 (MSK) Received: by mail-lf1-f66.google.com with SMTP id z22so17100597lfd.0 for ; Thu, 28 May 2020 10:34:26 -0700 (PDT) Date: Thu, 28 May 2020 20:34:23 +0300 From: Cyrill Gorcunov Message-ID: <20200528173423.GG215590@grain> References: <20200528100738.221911-1-gorcunov@gmail.com> <20200528100738.221911-7-gorcunov@gmail.com> <6ec85e2f-93a6-250d-63a9-a18c4caddb7d@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6ec85e2f-93a6-250d-63a9-a18c4caddb7d@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v4 6/8] lua/log: use log module settings inside box.cfg List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lvasiliev Cc: tml On Thu, May 28, 2020 at 08:07:02PM +0300, lvasiliev wrote: > > +local function apply_default_modules_cfg(cfg) > > Looks like apply_default_cfg(cfg, log.box_api.cfg). > Can we avoid code duplication? The problem is keys naming. The module may have own mapping. For example in my latest version we use variables without log_ prefix but for box module sake we provide a map log.lua ======= -- Name mapping from box to log module. -- Make sure all required fields are covered! local log2box_keys = { ['log'] = 'log', ['nonblock'] = 'log_nonblock', ['level'] = 'log_level', ['format'] = 'log_format', } -- Apply defaut config to the box module local function box_cfg_apply_default(box_cfg) for k, v in pairs(log_cfg) do if box_cfg[log2box_keys[k]] == nil then box_cfg[log2box_keys[k]] = v end end end load_cfg.lua ============ -- Fetch default settings from modules. local function apply_default_modules_cfg(cfg) log.box_api.cfg_apply_default(cfg) end This isolate module specifics from box variables as it should be I believe. > > > + -- > > + -- logging > > + for k,v in pairs(log.box_api.cfg) do > > Add a space before v. already reworked, thanks! > > @@ -146,7 +162,8 @@ local function log_rotate() > > end > > local function log_level(level) > > - return ffi.C.say_set_log_level(level) > > + ffi.C.say_set_log_level(level) > > + rawset(log_cfg, 'log_level', level) > > Maybe I'm wrong, but seems like after that change the ffi.C.log_level > is deprecated (log_cfg.log_level can be used instead). But now you > keep 'level' in two places (ffi.C.log_level and log_cfg.log_level). Not sure I follow here. You mean to drop their usage in Lua's "function say()" in this module? > > setmetatable(log, { > > + __serialize = function(self) > > Can you add a test on __serizlize? Good point, will do.