Module logger

Logging helper.

Writes to a log file and prints to the console.

This module is a lua script (logger.lua), you need to explicitly load it with require('logger')

Usage:

    require('logger')
    
    local log = logger("MYLOG.LOG")
    log:write("hello world!")
    log:close()

Functions

logger(filename[, listener]) Creates a new logger
tolines(str) Splits a string into a table consisting of the lines of the original string

Class logger

logger:write(str) Writes a string to the log
logger:writef(fmt, ...) Writes a printf style formatted string to the log
logger:serialize(o) Converts any Lua type to a string representation and logs it.
logger:close() Close the log


Functions

logger(filename[, listener])
Creates a new logger

Parameters:

  • filename string the filename of the log file
  • listener table an additional 'listener' to write data to, should implement a t:write(str) function (optional)

Returns:

    logger the new instance
tolines(str)
Splits a string into a table consisting of the lines of the original string

Parameters:

Class logger

logger:write(str)
Writes a string to the log

Parameters:

  • str the string
logger:writef(fmt, ...)
Writes a printf style formatted string to the log

Parameters:

  • fmt string format string
  • ... format arguments
logger:serialize(o)
Converts any Lua type to a string representation and logs it. Recursively enumerates table structures

Parameters:

  • o the object to serialize
logger:close()
Close the log
generated by LDoc 1.4.3 Last updated 2018-12-23 23:12:04