Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] lua/log: accept symbolic logging levels
@ 2021-05-07 11:13 Cyrill Gorcunov via Tarantool-patches
  2021-05-07 11:17 ` Cyrill Gorcunov via Tarantool-patches
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-05-07 11:13 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

Currently `log` module accepts only numeric values of
logging levels. I turn `box.cfg` interface supports
symbolic names (such as 'fatat', 'crit' and etc).

Thus we should support the same in `log` module.

Closes #5882

Reported-by: Alexander Turenko <alexander.turenko@tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
issue https://github.com/tarantool/tarantool/issues/5882
branch gorcunov/gh-5882-logger-strings

 changelogs/unreleased/gh-5882-log-levels.md | 13 +++++++++++++
 src/lua/log.lua                             |  6 ++++++
 2 files changed, 19 insertions(+)
 create mode 100644 changelogs/unreleased/gh-5882-log-levels.md

diff --git a/changelogs/unreleased/gh-5882-log-levels.md b/changelogs/unreleased/gh-5882-log-levels.md
new file mode 100644
index 000000000..08f9595be
--- /dev/null
+++ b/changelogs/unreleased/gh-5882-log-levels.md
@@ -0,0 +1,13 @@
+## feature/lua/log
+
+ * Implemented support of symbolic log levels representation
+   in `log` module (gh-5882). Now it is possible to specify
+   levels the same way as in `box.cfg{}` call. For example
+   instead of
+   ``` Lua
+   require('log').cfg{level = 6}
+   ```
+   One can use
+   ``` Lua
+   require('log').cfg{level = 'verbose'}
+   ```
diff --git a/src/lua/log.lua b/src/lua/log.lua
index 62ea61f2d..788560722 100644
--- a/src/lua/log.lua
+++ b/src/lua/log.lua
@@ -499,6 +499,12 @@ local function load_cfg(self, cfg)
             local m = "log.cfg: \'%s\' %s"
             error(m:format('level', msg))
         end
+        -- Convert level to a numeric value since
+        -- low level api operates with numbers only.
+        if type(cfg.level) == 'string' then
+            assert(log_level_keys[cfg.level] ~= nil)
+            cfg.level = log_level_keys[cfg.level]
+        end
     end
 
     if cfg.nonblock ~= nil then
-- 
2.30.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-01 12:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 11:13 [Tarantool-patches] [PATCH] lua/log: accept symbolic logging levels Cyrill Gorcunov via Tarantool-patches
2021-05-07 11:17 ` Cyrill Gorcunov via Tarantool-patches
2021-05-26 11:04 ` Serge Petrenko via Tarantool-patches
2021-05-26 22:04 ` Alexander Turenko via Tarantool-patches
2021-05-27  7:53   ` Cyrill Gorcunov via Tarantool-patches
2021-05-27  9:04     ` Alexander Turenko via Tarantool-patches
2021-05-27 10:17       ` Cyrill Gorcunov via Tarantool-patches
2021-06-01 12:25 ` Kirill Yukhin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox