Software /
code /
prosody
Comparison
tests/util/logger.lua @ 7921:1821a7cabaa5
tests/util.logger: Remove use of deprecated module function
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 27 Feb 2017 15:17:12 +0100 |
parent | 5776:bd0ff8ae98a8 |
comparison
equal
deleted
inserted
replaced
7920:1db51061342b | 7921:1821a7cabaa5 |
---|---|
12 local tostring = tostring; | 12 local tostring = tostring; |
13 | 13 |
14 local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; | 14 local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; |
15 local do_pretty_printing = not os.getenv("WINDIR"); | 15 local do_pretty_printing = not os.getenv("WINDIR"); |
16 | 16 |
17 module "logger" | 17 local _ENV = nil |
18 local _M = {} | |
18 | 19 |
19 local logstyles = {}; | 20 local logstyles = {}; |
20 | 21 |
21 --TODO: This should be done in config, but we don't have proper config yet | 22 --TODO: This should be done in config, but we don't have proper config yet |
22 if do_pretty_printing then | 23 if do_pretty_printing then |
23 logstyles["info"] = getstyle("bold"); | 24 logstyles["info"] = getstyle("bold"); |
24 logstyles["warn"] = getstyle("bold", "yellow"); | 25 logstyles["warn"] = getstyle("bold", "yellow"); |
25 logstyles["error"] = getstyle("bold", "red"); | 26 logstyles["error"] = getstyle("bold", "red"); |
26 end | 27 end |
27 | 28 |
28 function init(name) | 29 function _M.init(name) |
29 --name = nil; -- While this line is not commented, will automatically fill in file/line number info | 30 --name = nil; -- While this line is not commented, will automatically fill in file/line number info |
30 return function (level, message, ...) | 31 return function (level, message, ...) |
31 if level == "debug" or level == "info" then return; end | 32 if level == "debug" or level == "info" then return; end |
32 if not name then | 33 if not name then |
33 local inf = debug.getinfo(3, 'Snl'); | 34 local inf = debug.getinfo(3, 'Snl'); |