LuaLogging
A simple API to use logging features in Lua.

Console appender

Console is the simplest appender. It just writes the log messages to io.stdout or io.stderr.

function logging.console {
    [destination = "stdout"|"stderr",]

    [logPattern = string,]
    [logPatterns = {
      [logging.DEBUG = string,]
      [logging.INFO  = string,]
      [logging.WARN  = string,]
      [logging.ERROR = string,]
      [logging.FATAL = string,]
    },]
    [timestampPattern = string,]
    [logLevel = log-level-constant,]
}
  • 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().
  • destination:
    The destination stream, optional. The value can be either "stdout", or "stderr". The default is stdout.
  • logLevel:
    The initial log-level to set for the created logger.

Examples

require"logging.console"

local logger = logging.console()

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

 

 

 

 

 

 

 

XHTML 1.0 válido!