Skip to content

Commit

Permalink
fix(error-log-logger): the logger should be run in each process
Browse files Browse the repository at this point in the history
Fix apache#3911

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Mar 26, 2021
1 parent 83ab543 commit c3144f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apisix/plugins/error-log-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ local function process()

end

local id = ngx.worker.id()
local id = ngx.worker.id() or -1
local entries = {}
local logs = errlog.get_logs(9)
while ( logs and #logs>0 ) do
Expand Down Expand Up @@ -198,12 +198,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

0 comments on commit c3144f0

Please sign in to comment.