diff --git a/lualib/resty/events/callback.lua b/lualib/resty/events/callback.lua index 7d25070b..c36ff536 100644 --- a/lualib/resty/events/callback.lua +++ b/lualib/resty/events/callback.lua @@ -116,8 +116,9 @@ function _M:do_event(d) local now = ngx.now() if time then - log(DEBUG, "worker-events: receive event; source=", source, - ", event=", event, ", wid=", wid, ", time=", now - time) + log(DEBUG, "worker-events [receive]: source=", source, + ", event=", event, ", wid=", wid, ", time=", now - time, + ", data=", cjson_encode(data)) end log(DEBUG, "worker-events: handling event; source=", source, @@ -139,8 +140,9 @@ function _M:do_event(d) do_handlerlist(funcs, list, source, event, data, wid) ngx.update_time() - log(DEBUG, "worker-events: done event; source=", source, - ", event=", event, ", wid=", wid, ", time=", ngx.now() - now) + log(DEBUG, "worker-events [done] : source=", source, + ", event=", event, ", wid=", wid, ", time=", ngx.now() - now, + ", data=", encode(data)) end diff --git a/lualib/resty/events/queue.lua b/lualib/resty/events/queue.lua index a6ee240f..30a3b02c 100644 --- a/lualib/resty/events/queue.lua +++ b/lualib/resty/events/queue.lua @@ -1,3 +1,4 @@ +local cjson = require "cjson.safe" local semaphore = require "ngx.semaphore" local table_new = require "table.new" @@ -26,7 +27,7 @@ function _M.new(max_len) income = 0, } - ngx.log(ngx.DEBUG, "worker-events: queue init, max_len=", self.max_len) + ngx.log(ngx.DEBUG, "worker-events [queue]: init, max_len=", self.max_len) return setmetatable(self, _MT) end @@ -37,8 +38,9 @@ function _M:push(item) local count = last - self.first + 1 - ngx.log(ngx.DEBUG, "worker-events: push queue, len=", count, - ", income=", self.income, ", outcome=", self.outcome) + ngx.log(ngx.DEBUG, "worker-events [queue]: push , len=", count, + ", income=", self.income, ", outcome=", self.outcome, + ", data=", cjson_encode(item)) if count >= self.max then return nil, "queue overflow" @@ -76,8 +78,9 @@ function _M:pop() local count = self.last - self.first + 1 - ngx.log(ngx.DEBUG, "worker-events: pop queue, len=", count, - ", income=", self.income, ", outcome=", self.outcome) + ngx.log(ngx.DEBUG, "worker-events [queue]: pop , len=", count, + ", income=", self.income, ", outcome=", self.outcome, + ", data=", cjson_encode(item)) return item end diff --git a/lualib/resty/events/worker.lua b/lualib/resty/events/worker.lua index c17460ae..a9a750df 100644 --- a/lualib/resty/events/worker.lua +++ b/lualib/resty/events/worker.lua @@ -335,7 +335,7 @@ function _M:publish(target, source, event, data) assert(type(source) == "string" and source ~= "", "source is required") assert(type(event) == "string" and event ~= "", "event is required") - log(DEBUG, "source=", source, ", event=", event, ", data=", cjson_encode(data)) + log(DEBUG, "[publish] source=", source, ", event=", event, ", data=", cjson_encode(data)) -- fall back to local events if self._opts.testing == true then