Skip to content

Commit b02f3dc

Browse files
committed
Put debug logging behind a flag
1 parent 3e4cb6f commit b02f3dc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/resty/http.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ local DEFAULT_PARAMS = {
126126
}
127127

128128

129+
local DEBUG = false
130+
131+
129132
function _M.new(_)
130133
local sock, err = ngx_socket_tcp()
131134
if not sock then
@@ -135,6 +138,11 @@ function _M.new(_)
135138
end
136139

137140

141+
function _M.debug(d)
142+
DEBUG = (d == true)
143+
end
144+
145+
138146
function _M.set_timeout(self, timeout)
139147
local sock = self.sock
140148
if not sock then
@@ -647,7 +655,7 @@ function _M.send_request(self, params)
647655

648656
-- Format and send request
649657
local req = _format_request(params)
650-
ngx_log(ngx_DEBUG, "\n", req)
658+
if DEBUG then ngx_log(ngx_DEBUG, "\n", req) end
651659
local bytes, err = sock:send(req)
652660

653661
if not bytes then

0 commit comments

Comments
 (0)