Skip to content

Commit

Permalink
fix(cmd): fix kong cli not printing some debug level error log
Browse files Browse the repository at this point in the history
  • Loading branch information
windmgc committed Jun 4, 2024
1 parent 3066f50 commit 404ac43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/kong
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions spec/02-integration/02-cmd/16-verbose_spec.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 404ac43

Please sign in to comment.