|
| LuaLogging |
| A simple API to use logging
features in Lua |
home · manual · example
· console · email · file · socket · sql
File appender
The file appender can be used to write log messages to a file. It
uses Lua I/O routines to do its job.
function logging.file(filename, [datePattern],
[logPattern])
filename:
The name of the file to be written to. On each call to log a
message the file is opened for appending and closed
immediately.
If the file cannot be opened for appending the logging request
returns nil and an error message.
datePattern:
This is an optional parameter that can be used to specify a date
pattern that will be passed to the os.date
function to compose the filename.
This is useful to create daily or monthly log files. If the user
wants to create one log file per day he specifies a
"%Y-%m-%d" pattern and a filename like
"temp%s.log".
logPattern:
A pattern can be specified to control how the message is
written.
The default value is "%date %level %message\n".
Example
require"logging.file"
local logger = logging.file("test%s.log", "%Y-%m-%d")
logger:info("logging.file test")
logger:debug("debugging...")
logger:error("error!")
$Id: index.html,v 1.1 2004/11/16 16:33:10 tuler Exp
$