Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements #11

Open
nottledim opened this issue May 9, 2020 · 0 comments
Open

Enhancements #11

nottledim opened this issue May 9, 2020 · 0 comments

Comments

@nottledim
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant