Mercurial > prosody-hg
comparison util/logger.lua @ 806:655293df3d7e
Merge waqas with waqas
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 16 Feb 2009 15:44:23 +0000 |
| parents | 5fbbf34ef1c4 |
| children | 0112ae30f399 |
comparison
equal
deleted
inserted
replaced
| 804:9bc1544c99b7 | 806:655293df3d7e |
|---|---|
| 31 | 31 |
| 32 local outfunction = nil; | 32 local outfunction = nil; |
| 33 | 33 |
| 34 function init(name) | 34 function init(name) |
| 35 --name = nil; -- While this line is not commented, will automatically fill in file/line number info | 35 --name = nil; -- While this line is not commented, will automatically fill in file/line number info |
| 36 sourcewidth = math_max(#name+2, sourcewidth); | |
| 37 local namelen = #name; | 36 local namelen = #name; |
| 38 return function (level, message, ...) | 37 return function (level, message, ...) |
| 39 if not name then | |
| 40 local inf = debug.getinfo(3, 'Snl'); | |
| 41 level = level .. ","..tostring(inf.short_src):match("[^/]*$")..":"..inf.currentline; | |
| 42 end | |
| 43 | |
| 44 if outfunction then return outfunction(name, level, message, ...); end | 38 if outfunction then return outfunction(name, level, message, ...); end |
| 45 | 39 |
| 40 sourcewidth = math_max(#name+2, sourcewidth); | |
| 46 if ... then | 41 if ... then |
| 47 io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", format(message, ...), "\n"); | 42 io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", format(message, ...), "\n"); |
| 48 else | 43 else |
| 49 io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", message, "\n"); | 44 io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", message, "\n"); |
| 50 end | 45 end |
