Skip to content
Open
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
12 changes: 8 additions & 4 deletions lib/resty/logger/socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ local max_retry_times = 3
local retry_interval = 100 -- 0.1s
local pool_size = 10
local flushing
local logger_initted
local logger_initted = false
local counter = 0
local ssl_session

Expand Down Expand Up @@ -328,7 +328,7 @@ local function _flush()
return bytes
end

local function _periodic_flush(premature)
local function _periodic_flush(premature, initted)
if premature then
exiting = true
end
Expand All @@ -347,7 +347,11 @@ local function _periodic_flush(premature)
need_periodic_flush = true
end

timer_at(periodic_flush, _periodic_flush)
if not initted then
return
end

timer_at(periodic_flush, _periodic_flush, logger_initted)
end

local function _flush_buffer()
Expand Down Expand Up @@ -488,7 +492,7 @@ function _M.init(user_config)
.. periodic_flush .. " seconds")
end
need_periodic_flush = true
timer_at(periodic_flush, _periodic_flush)
timer_at(periodic_flush, _periodic_flush, logger_initted)
end

return logger_initted
Expand Down