log.lua icon indicating copy to clipboard operation
log.lua copied to clipboard

Enhancements

Open nottledim opened this issue 5 years ago • 0 comments

Nice wee module! I've learned a lot from it. Many thanks. Some minor changes you could make:

  • if you change function spec of log.level from log[x.name] = function(...) to log[x.name] = function(fmt, ...) you can then append fmt to your format string print(string.format("%s[%-6s%s]%s %s: " .. fmt, ...) and allow the calls to use param substitution e.g: log.error("Some error no: %d", errno)

  • Add export log.levels = levels so the list of level strings can be accessed and tested against : if log.levels[level] then etc

  • Add function log.log() where first param is level makes dynamic level change easy: log.log = function(level, ...) if levels[level] then log[level](...) else log[log.level](...) end end

nottledim avatar May 09 '20 14:05 nottledim