What is it -------------------------------------------------------------------------------- lsyslog is a Lua module that wraps the syslog(3) C API. It has been tested with lua 5.1 on Linux. Download -------------------------------------------------------------------------------- The latest version can be found at LuaForge. Compiling -------------------------------------------------------------------------------- To compile the module, just edit the Makefile to reflect your installation of Lua. Then run make. This will build the library and run a simple test. Installing -------------------------------------------------------------------------------- To intall the module, just copy syslog.so somewhere in your LUA_CPATH. Usage The library exports the following Lua functions: * openlog(ident, option[, facility]) * syslog(priority, message) * closelog() See test.lua, which shows the library in action. You may want to wap the standard assert and error Lua calls so that they log the assertion or error before aborting the program. This can be useful for post-mortem analysis of embedded or unattended Lua applications. You can append this code at the end of strict.lua, a module that can be found in the etc directory of the Lua sources, and which is worth including anyway. ---- Begin Code require "syslog" -- set the ident string to the filename that first included this module syslog.openlog(debug.getinfo(3, "S").short_src, syslog.LOG_ODELAY, "LOG_USER") local _error = error error = function(txt, level) if level then level = level + 1 else level = 2 end local info = debug.getinfo(level, "Sl") local msg if info.what == "C" then msg = "[C function] " else msg = string.format("[%s]:%d ", info.short_src, info.currentline) end syslog.syslog("LOG_ERR", msg .. (txt or "")) _error(txt, level) end _G.assert = function (...) local cond, txt = ... if not cond then error(txt or "assertion failed!", 2) end return ... end --- End Code Then call require "strict" at the top of your code. License ---------------------------------------------------------------------------- This code is hereby placed in the public domain. Please send comments, suggestions, and bug reports to jesus.ruizdeinfante@hale.at . Thanks ---------------------------------------------------------------------------- Thanks to Luiz Henrique de Figueiredo for the Makefile.