LuaLogging
A simple API to use logging features in Lua.

Email appender

This appender can be used to send log requests through email. One email message is sent for each log request.

function logging.email {
    from = string,
    rcpt = string or string-table,
    [user = string,]
    [password = string,]
    [server = string,]
    [port = number,]
    [domain = string,]
    [headers = table,]

    [logPattern = string,]
    [logPatterns = {
      [logging.DEBUG = string,]
      [logging.INFO  = string,]
      [logging.WARN  = string,]
      [logging.ERROR = string,]
      [logging.FATAL = string,]
    },]
    [timestampPattern = string,]
    [logLevel = log-level-constant,]
}
  • from:
    The sender of the email message.
  • rcpt:
    The recipient of the email message. A string or a numerically indexed Lua table with strings.
  • user:
    User for authentication.
  • password:
    Password for authentication.
  • server:
    Server to connect to. Default is "localhost".
  • port:
    Port to connect to. Default is 25.
  • domain:
    Domain name used to greet the server. Defaults to the local machine host name.
  • headers.to:
    The recipient of the message, as an extended description.
  • headers.from:
    The sender of the message, as an extended description.
  • headers.subject:
    The subject of the message sent. This can contain patterns like the logPattern parameter.
  • logPatterns:
    A table with logPattern strings indexed by the log-levels. A logPattern specifies how the message is written.
    If this parameter is omitted, a patterns table will be created with the parameter logPattern as the default value for each log-level. If logPattern also is omitted then each level will fall back to the current default setting, see logging.defaultLogPatterns.
  • logPattern:
    This value will be used as the default value for each log-level that was omitted in logPatterns.
  • timestampPattern:
    This is an optional parameter that can be used to specify a date/time formatting in the log message. The default is taken from logging.defaultTimestampPattern().
  • logLevel:
    The initial log-level to set for the created logger.

Example

require"logging.email"

local logger = logging.email {
  rcpt = "mail@host.com",
  from = "mail@host.com",
  headers = {
    subject = "[%level] logging.email test",
  },
}

logger:info("logging.email test")
logger:debug("debugging...")
logger:error("error!")

XHTML 1.0 válido!