Comparison

util/logger.lua @ 30:bcf539295f2d

Huge commit to: * Break stanza routing (to be restored in a future commit) * Remove the old stanza_dispatcher code, which was never going to be maintainable nor extendable :) * Bring us plugins, starting with mod_legacyauth and mod_roster * Sessions are now created/destroyed using a standard sessionmanager interface
author Matthew Wild <mwild1@gmail.com>
date Tue, 30 Sep 2008 19:52:00 +0100
child 53:14ea0fe6ca86
comparison
equal deleted inserted replaced
29:b847875801e5 30:bcf539295f2d
1
2 local format = string.format;
3 local print = print;
4 local debug = debug;
5 local tostring = tostring;
6 module "logger"
7
8 function init(name)
9 name = nil; -- While this line is not commented, will automatically fill in file/line number info
10 return function (level, message, ...)
11 if not name then
12 local inf = debug.getinfo(2, 'Snl');
13 level = level .. ","..tostring(inf.short_src):match("[^/]*$")..":"..inf.currentline;
14 end
15 if ... then
16 print(level, format(message, ...));
17 else
18 print(level, message);
19 end
20 end
21 end
22
23 return _M;