ngx.log(ngx.ERR,"The configuration option syslog_port is NOT defined !")
end
port=tonumber(port)
flush_limit=tonumber(flush_limit)
drop_limit=tonumber(drop_limit)
periodic_flush=tonumber(periodic_flush)
self.host=config.syslog_host
self.port=tonumber(config.syslog_port)
ngx.log(ngx.WARN,"Sending custom logs to "..proto.."://"..(hostor"")..":"..(portor"").." with flush_limit = "..flush_limit.." bytes, periodic_flush = "..periodic_flush.." sec. and drop_limit = "..drop_limit.." bytes")
ngx.log(ngx.WARN,"Sending custom logs to "..self.proto.."://"..(self.hostor"")..":"..(self.portor"").." with flush_limit = "..self.flush_limit.." bytes, periodic_flush = "..self.periodic_flush.." sec. and drop_limit = "..self.drop_limit.." bytes")
returnapicast:init()
returnself
end
-- Initialize the underlying logging module. Since the module calls 'timer_at'
-- during initialization, we need to call it from a init_worker_by_lua block.
--
function_M:init_worker()
ngx.log(ngx.INFO,"Initializing the underlying logger")
ensure_logger_is_initted(self)
end
localfunctionensure_logger_is_initted(self)
ifnotlogger.initted()then
ngx.log(ngx.INFO,"Initializing the underlying logger")
-- default parameters
localparams={
host=host,
port=port,
sock_type=proto,
flush_limit=flush_limit,
drop_limit=drop_limit
host=self.host,
port=self.port,
sock_type=self.proto,
flush_limit=self.flush_limit,
drop_limit=self.drop_limit
}
-- periodic_flush == 0 means 'disable this feature'
ifperiodic_flush>0then
params["periodic_flush"]=periodic_flush
ifself.periodic_flush>0then
params["periodic_flush"]=self.periodic_flush
end
-- initialize the logger
@ -76,12 +71,9 @@ function _M:init_worker()
ngx.log(ngx.ERR,"failed to initialize the logger: ",err)
end
end
returnapicast:init_worker()
end
functiondo_log(payload)
localfunctiondo_log(payload)
-- construct the custom access log message in
-- the Lua variable "msg"
--
@ -95,8 +87,8 @@ end
-- This function is called for each chunk of response received from upstream server
-- when the last chunk is received, ngx.arg[2] is true.