Skip to content
Draft
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
10 changes: 10 additions & 0 deletions apisix/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ local config_schema = {
is_print_return_value = {
type = "boolean",
},
is_print_traceback = {
type = "boolean",
},
}
},
},
Expand Down Expand Up @@ -192,6 +195,13 @@ local function apply_new_fun(module, fun_name, file_path, hook_conf)
end
end

if hook_conf.is_print_traceback then
if enable_by_hook or enable_by_header_filter then
log[log_level]("call require(\"", file_path, "\").", fun_name,
"() call stack:", debug.traceback())
end
end

local ret = {self.fun_org(...)}
if hook_conf.is_print_return_value then
if enable_by_hook or enable_by_header_filter then
Expand Down
30 changes: 30 additions & 0 deletions t/debug/hook.t
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,33 @@ hello world
--- error_log
read_debug_yaml(): failed to validate debug config property "hook_conf" is required
--- wait: 3



=== TEST 6: basic print_traceback enabled with static hook
--- debug_config
basic:
enable: true
http_filter:
enable: false
hook_conf:
enable: true
name: hook_test
log_level: warn
is_print_input_args: false
is_print_return_value: false
is_print_traceback: true

hook_test:
apisix:
- http_access_phase

#END
--- request
GET /hello
--- more_headers
Host: foo.com
--- response_body
hello world
--- error_log
call require("apisix").http_access_phase() call stack:stack traceback:
Loading