author | Matthew Wild <mwild1@gmail.com> |
Wed, 01 May 2013 13:54:00 +0100 | |
branch | s2s |
changeset 5558 | 774ab5f2efa6 |
parent 147 | ccebb2720741 |
child 259 | 1485d272400d |
permissions | -rw-r--r-- |
30 | 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) |
|
147 | 9 |
--name = nil; -- While this line is not commented, will automatically fill in file/line number info |
30 | 10 |
return function (level, message, ...) |
11 |
if not name then |
|
53
14ea0fe6ca86
Session destruction fixes, some debugging code while we fix the rest. Also change logger to be more useful.
Matthew Wild <mwild1@gmail.com>
parents:
30
diff
changeset
|
12 |
local inf = debug.getinfo(3, 'Snl'); |
30 | 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; |