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");
21 --TODO: This should be done in config, but we don't have proper config yet
22 if do_pretty_printing then
23 logstyles["info"] = getstyle("bold");
24 logstyles["warn"] = getstyle("bold", "yellow");
25 logstyles["error"] = getstyle("bold", "red");
29 --name = nil; -- While this line is not commented, will automatically fill in file/line number info
30 return function (level, message, ...)
31 if level == "debug" or level == "info" then return; end
33 local inf = debug.getinfo(3, 'Snl');
34 level = level .. ","..tostring(inf.short_src):match("[^/]*$")..":"..inf.currentline;
37 print(name, getstring(logstyles[level], level), format(message, ...));
39 print(name, getstring(logstyles[level], level), message);