|
| LuaLogging Reference Manual |
| A simple API to use logging features in Lua |
LuaLogging is a simple API to use logging features in Lua. Its design is based on log4j.
LuaLogging defines one single global variable, a table called
logging
which holds the function that creates new loggers.
A logger object offers methods that writes log messages. To create a logger you simply call the function:
filename is the name of the file to be written to.
The application must have write permissions to the specified file.logger object.
message may be any lua value, not just strings. The same applies to all the functions below.
level is one of the variables enumerated here.
require "logging"
local logger = logging.new("/tmp/test.log")
logger:setLevel (logging.WARN)
logger:log(logging.INFO, "sending email")
logger:info("trying to contact server")
logger:warn("server did not responded yet")
logger:error("server unreachable")
Upon execution the file "/tmp/test.log" contains the following lines.06/17/04 16:21:15 WARN server did not responded yet 06/17/04 16:21:20 ERROR server unreachable
Not implemented (yet)