From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 90674469710 for ; Mon, 25 May 2020 18:43:28 +0300 (MSK) References: <20200525121715.21216-1-gorcunov@gmail.com> <20200525121715.21216-8-gorcunov@gmail.com> From: Oleg Babin Message-ID: Date: Mon, 25 May 2020 18:43:27 +0300 MIME-Version: 1.0 In-Reply-To: <20200525121715.21216-8-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 07/10] 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: Cyrill Gorcunov , tml Cc: Alexander Turenko Hi! Thanks for your patch! See my comments below. On 25/05/2020 15:17, Cyrill Gorcunov wrote: > > local function log_pid() > @@ -197,6 +215,18 @@ return setmetatable({ > pid = log_pid; > level = log_level; > log_format = log_format; > + cfg = cfg, > + -- > + -- Internal API to box module, not for users, > + -- names can be changed. > + box_api = { > + set_log_level = function() > + log_level(box.cfg.log_level) > + end, > + set_log_format = function() > + log_format(box.cfg.log_format) > + end, > + } > }, { > __index = compat_v16; > }) > I think we should hide internal functions from user as it is done e.g. in fiber module: https://github.com/tarantool/tarantool/blob/master/src/lua/fiber.lua#L89 Also I thinks we shouldn't expose some of functions: ```lua tarantool> log = require('log') --- ... tarantool> log --- - level: 'function: 0x010c087cd8' log_format: 'function: 0x010c069d08' info: 'function: 0x010c0a3d18' pid: 'function: 0x010c09db10' error: 'function: 0x010c042410' warn: 'function: 0x010c0a2048' box_api: cfg_update: 'function: 0x010c09e248' set_log_level: 'function: 0x010c047818' set_log_format: 'function: 0x010c070f78' cfg: log_level: 5 log_format: plain debug: 'function: 0x010c0a6130' init: 'function: 0x010c0762a0' rotate: 'function: 0x010c08b7d0' verbose: 'function: 0x010c0a4758' ... tarantool> log.logger_pid() -- shouldn't be exposed if deprecated logger_pid() is deprecated, please use pid() instead --- - 0 ... ``` And IMO it will be great if an interface that will be similar to box.cfg/json.cfg/yaml.cfg... - log.cfg({...}). For that we can add __call metamethod for cfg table.