ngx.log(ngx.ERR,"The environment SYSLOG_HOST is NOT defined !")
ngx.log(ngx.ERR,"The environment SYSLOG_HOST is NOT defined !")
@ -27,8 +42,18 @@ function _M:init()
port=tonumber(port)
port=tonumber(port)
flush_limit=tonumber(flush_limit)
flush_limit=tonumber(flush_limit)
drop_limit=tonumber(drop_limit)
drop_limit=tonumber(drop_limit)
ngx.log(ngx.WARN,"Sending custom logs to "..proto.."://"..host..":"..port.." with flush_limit = "..flush_limit.." and drop_limit = "..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")
returnapicast:init()
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")
ifnotlogger.initted()then
ifnotlogger.initted()then
localok,err=logger.init{
localok,err=logger.init{
host=host,
host=host,
@ -36,20 +61,24 @@ function _M:init()
sock_type=proto,
sock_type=proto,
flush_limit=flush_limit,
flush_limit=flush_limit,
drop_limit=drop_limit,
drop_limit=drop_limit,
periodic_flush=periodic_flush
}
}
ifnotokthen
ifnotokthen
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()
returnapicast:init_worker()
end
end
functiondo_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"
localbytes,err=logger.log(payload)
--
-- do not forget the \n in order to have one request per line on the syslog server