2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local format = string.format;
12 local tostring = tostring;
14 local getstyle
, getstring
= require
"util.termcolours".getstyle
, require
"util.termcolours".getstring
;
15 local do_pretty_printing
= not os
.getenv("WINDIR");
22 --TODO: This should be done in config, but we don't have proper config yet
23 if do_pretty_printing
then
24 logstyles
["info"] = getstyle("bold");
25 logstyles
["warn"] = getstyle("bold", "yellow");
26 logstyles
["error"] = getstyle("bold", "red");
29 function _M
.init(name
)
30 --name = nil; -- While this line is not commented, will automatically fill in file/line number info
31 return function (level
, message
, ...)
32 if level
== "debug" or level
== "info" then return; end
34 local inf
= debug
.getinfo(3, 'Snl');
35 level
= level
.. ","..tostring(inf
.short_src
):match("[^/]*$")..":"..inf
.currentline
;
38 print(name
, getstring(logstyles
[level
], level
), format(message
, ...));
40 print(name
, getstring(logstyles
[level
], level
), message
);