spacewander commented on a change in pull request #5012:
URL: https://github.com/apache/apisix/pull/5012#discussion_r711421451
##########
File path: docs/zh/latest/architecture-design/debug-mode.md
##########
@@ -85,3 +85,25 @@ hook_phase: # 模块函数列表,名字:hook_phase
- http_log_phase
#END
```
+
+### 动态高级调试模式
+
+动态高级调试模式是基于高级调试模式,可以由单个请求动态开启高级调试模式,请求结束后自动关闭。设置 `conf/debug.yaml` 中的选项。
Review comment:
We don't disable it when the request is finished, better not to mention
it.
##########
File path: apisix/debug.lua
##########
@@ -123,15 +124,35 @@ local function apple_new_fun(module, fun_name, file_path,
hook_conf)
function mt.__call(self, ...)
local arg = {...}
+ local http_filter = debug_yaml.http_filter
+ local api_ctx = ngx.ctx.api_ctx
+ local enable_by_hook = not (http_filter and http_filter.enable)
+ or (api_ctx and api_ctx.enable_dynamic_debug)
Review comment:
We don't need this part. When not http_filter, there won't be
api_ctx.enable_dynamic_debug too
##########
File path: apisix/debug.lua
##########
@@ -123,15 +124,35 @@ local function apple_new_fun(module, fun_name, file_path,
hook_conf)
function mt.__call(self, ...)
local arg = {...}
+ local http_filter = debug_yaml.http_filter
+ local api_ctx = ngx.ctx.api_ctx
+ local enable_by_hook = not (http_filter and http_filter.enable)
+ or (api_ctx and api_ctx.enable_dynamic_debug)
+ local enable_by_header_filter = (http_filter and http_filter.enable)
+ and (api_ctx and api_ctx.enable_dynamic_debug)
if hook_conf.is_print_input_args then
- log[log_level]("call require(\"", file_path, "\").", fun_name,
- "() args:", json.delay_encode(arg, true))
+ if enable_by_hook then
Review comment:
```suggestion
if enable_by_hook or enable_by_header_filter then
```
##########
File path: apisix/debug.lua
##########
@@ -30,6 +29,7 @@ local setmetatable = setmetatable
local pcall = pcall
local ipairs = ipairs
local unpack = unpack
+local inspect = require "inspect"
Review comment:
Actually I mean to use `require("inspect")`, the
`require("ngx.process")` is just an example.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]