From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D9D816EC55; Fri, 7 May 2021 14:13:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D9D816EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1620385991; bh=UOp5kYFKkxOxyYPeK2COpjPINWAIQvybZ/C0K8W5c78=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=fn/LMoEJlF0QOqsoihC4nBfROAPmZLYZAuCck8DtatljeffvHqm4F5h4a9qGQa1Yc NPbet4asMIeIMGiDEI1QvrFyYZ0oS2bHDJsWToPeRO7k64gKxazLEELKXmD+WHk1ZN 2F2BUPQobdPYXFmd2eeipS/yhtKmjxQ2B6ZtSofY= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1E7D56EC55 for ; Fri, 7 May 2021 14:13:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1E7D56EC55 Received: by mail-lf1-f49.google.com with SMTP id j10so12178858lfb.12 for ; Fri, 07 May 2021 04:13:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0IAjWK8ok1H/hb1oYk0XfXiJt8z+ppr35IEL2oTdeQA=; b=KFJav4XeBljP7X4AhK77o+DccUL7p2LI+nWhWnMxKdij9FtznOUaFfavbhEDLGnXUb 4N9M5/gAH4m3tI1RuWs7Q+CYje/yPu+V/H8fbfg3yqOIxknvIaTDuUIMq7KvhorNyOgk 93MsDgE8pzSncIfbxhUnE+YZBVXq3VNQORDIplMgu0W4HG7I9v9PgYPNA/ampuT/Gi9T 8vgAowLdDe+nQHEbmXDz8pmE2diCf5ox/ZdcfJU8XlGofEl0wP9IV/HqmbtsQl9KtfvN RqcIRki2pGBmS/HsfvvQD6h76W9gmivr6oWMtDXSX1qfrSbZ+kWUtqYiZKHWX+W3R88p Om1g== X-Gm-Message-State: AOAM532YkXFhsgDs/4a77DkAjSFVx2keFeac8zKtivxP+/T6dFTOyiW1 SqSkJuZwR+EdvWX9jVgZ4mUty9n5uC8= X-Google-Smtp-Source: ABdhPJwvVN2D1mAl9Q2RWGs6uHSu0HmZ0sqgqaya3y931cibrg85abL99QzdNBVk520DuwlOrvMnHg== X-Received: by 2002:a05:6512:c13:: with SMTP id z19mr5863248lfu.311.1620385988849; Fri, 07 May 2021 04:13:08 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id h7sm1344573lfu.199.2021.05.07.04.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 04:13:07 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id DD08A5601EF; Fri, 7 May 2021 14:13:06 +0300 (MSK) To: tml Date: Fri, 7 May 2021 14:13:05 +0300 Message-Id: <20210507111305.564935-1-gorcunov@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] lua/log: accept symbolic logging levels X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Alexander Turenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 Signed-off-by: Cyrill Gorcunov --- 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