[Tarantool-patches] [PATCH 07/10] lua/log: use log module settings inside box.cfg
Oleg Babin
olegrok at tarantool.org
Mon May 25 18:43:27 MSK 2020
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.
More information about the Tarantool-patches
mailing list