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/changelog/unreleased/kong/fix-cmd-error-log.yml b/changelog/unreleased/kong/fix-cmd-error-log.yml new file mode 100644 index 000000000000..0c74fedac3f4 --- /dev/null +++ b/changelog/unreleased/kong/fix-cmd-error-log.yml @@ -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 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) diff --git a/spec/helpers.lua b/spec/helpers.lua index 57b9fea00da3..17f226e7bd08 100644 --- a/spec/helpers.lua +++ b/spec/helpers.lua @@ -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