Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cmd): fix kong cli not printing some debug level error log #13143

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions changelog/unreleased/kong/fix-cmd-error-log.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
Fixed an issue where some debug level error logs were not being displayed by the CLI.
type: bugfix
scope: CLI Command
11 changes: 11 additions & 0 deletions spec/02-integration/02-cmd/16-verbose_spec.lua
windmgc marked this conversation as resolved.
Show resolved Hide resolved
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)
3 changes: 2 additions & 1 deletion spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3312,7 +3312,8 @@ luassert:register("assertion", "partial_match", partial_match,
-- (ok, code, stdout, stderr); if `returns` is false,
-- returns either (false, stderr) or (true, stderr, stdout).
function exec(cmd, returns)
local ok, stdout, stderr, _, code = shell.run(cmd, nil, 0)
--100MB for retrieving stdout & stderr
local ok, stdout, stderr, _, code = shell.run(cmd, nil, 0, 1024*1024*100)
if returns then
return ok, code, stdout, stderr
end
Expand Down
Loading