Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(error-log-logger): the logger should be run in each process #3912

Merged
merged 2 commits into from
Mar 27, 2021
Merged
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
9 changes: 3 additions & 6 deletions apisix/plugins/error-log-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ local log_level = {


local config = {}
local buffers = {}
local log_buffer


local _M = {
Expand Down Expand Up @@ -149,7 +149,6 @@ local function process()

end

local id = ngx.worker.id()
local entries = {}
local logs = errlog.get_logs(9)
while ( logs and #logs>0 ) do
Expand All @@ -164,7 +163,6 @@ local function process()
return
end

local log_buffer = buffers[id]
if log_buffer then
for _, v in ipairs(entries) do
log_buffer:push(v)
Expand All @@ -189,7 +187,6 @@ local function process()
return
end

buffers[id] = log_buffer
for _, v in ipairs(entries) do
log_buffer:push(v)
end
Expand All @@ -198,12 +195,12 @@ end


function _M.init()
timers.register_timer("plugin#error-log-logger", process, true)
timers.register_timer("plugin#error-log-logger", process)
end


function _M.destroy()
timers.unregister_timer("plugin#error-log-logger", true)
timers.unregister_timer("plugin#error-log-logger")
end


Expand Down
1 change: 1 addition & 0 deletions t/plugin/error-log-logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use t::APISIX 'no_plan';
repeat_each(1);
no_long_string();
no_root_location();
master_on();

add_block_preprocessor(sub {
my ($block) = @_;
Expand Down