/usr/share/lua/5.1/logging/email.lua is in lua-logging 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | -------------------------------------------------------------------------------
-- Emails logging information to the given recipient
--
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
--
-- @copyright 2004-2013 Kepler Project
--
-------------------------------------------------------------------------------
local logging = require"logging"
local smtp = require"socket.smtp"
function logging.email(params)
params = params or {}
params.headers = params.headers or {}
if params.from == nil then
return nil, "'from' parameter is required"
end
if params.rcpt == nil then
return nil, "'rcpt' parameter is required"
end
return logging.new( function(self, level, message)
local s = logging.prepareLogMsg(params.logPattern, os.date(), level, message)
if params.headers.subject then
params.headers.subject =
logging.prepareLogMsg(params.headers.subject, os.date(), level, message)
end
local msg = { headers = params.headers, body = s }
params.source = smtp.message(msg)
local r, e = smtp.send(params)
if not r then
return nil, e
end
return true
end)
end
return logging.email
|