You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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(...)
tolog[x.name] = function(fmt, ...)
you can then append fmt to your format stringprint(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
etcAdd 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
The text was updated successfully, but these errors were encountered: