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