From 404ac43de576639ddb4b16d83d22ff7ae75739ce Mon Sep 17 00:00:00 2001 From: windmgc Date: Mon, 3 Jun 2024 15:42:23 +0800 Subject: [PATCH] fix(cmd): fix kong cli not printing some debug level error log --- bin/kong | 12 ++++++++++-- spec/02-integration/02-cmd/16-verbose_spec.lua | 11 +++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 spec/02-integration/02-cmd/16-verbose_spec.lua diff --git a/bin/kong b/bin/kong index 0ed5a347e615..7bbda5894e95 100755 --- a/bin/kong +++ b/bin/kong @@ -141,9 +141,17 @@ package.path = (os.getenv("KONG_LUA_PATH_OVERRIDE") or "") .. "./?.lua;./?/init. require("kong.cmd.init")("%s", %s) ]], cmd_name, args_str) +local resty_ngx_log_level +if arg.vv then + resty_ngx_log_level = "debug" +elseif arg.v then + resty_ngx_log_level = "info" +end + local resty_cmd = string.format( - "resty --main-conf \"%s\" --http-conf \"%s\" --stream-conf \"%s\" -e '%s'", - main_conf, http_conf, stream_conf, inline_code) + "resty %s --main-conf \"%s\" --http-conf \"%s\" --stream-conf \"%s\" -e '%s'", + resty_ngx_log_level and ("--errlog-level " .. resty_ngx_log_level) or "", main_conf, + http_conf, stream_conf, inline_code) local _, code = pl_utils.execute(resty_cmd) os.exit(code) diff --git a/spec/02-integration/02-cmd/16-verbose_spec.lua b/spec/02-integration/02-cmd/16-verbose_spec.lua new file mode 100644 index 000000000000..b0993c8dfa44 --- /dev/null +++ b/spec/02-integration/02-cmd/16-verbose_spec.lua @@ -0,0 +1,11 @@ +local helpers = require "spec.helpers" +local meta = require "kong.meta" + +describe("kong cli verbose output", function() + it("--vv outputs debug level log", function() + local _, stderr, stdout = assert(helpers.kong_exec("version --vv")) + -- globalpatches debug log will be printed by upper level resty command that runs kong.cmd + assert.matches("installing the globalpatches", stderr) + assert.matches("Kong: " .. meta._VERSION, stdout) + end) +end)