From 54990cab5371b0257f38a31ee3a6208060b0096a Mon Sep 17 00:00:00 2001 From: windmgc Date: Mon, 3 Jun 2024 15:42:23 +0800 Subject: [PATCH 1/2] fix(cmd): fix kong cli not printing some debug level error log --- bin/kong | 12 ++++++++++-- changelog/unreleased/kong/fix-cmd-error-log.yml | 4 ++++ spec/02-integration/02-cmd/16-verbose_spec.lua | 11 +++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/kong/fix-cmd-error-log.yml 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/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) From 53a5d803d3adc7a0eda094891378fb6a7a7c921f Mon Sep 17 00:00:00 2001 From: Niklaus Schen <8458369+Water-Melon@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:25:53 +0800 Subject: [PATCH 2/2] tests(helpers): specify a larger buffer to avoid read stalling issues caused by insufficient buffer size (#13163) --- spec/helpers.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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