Skip to content

Enhancements #11

Description

@nottledim

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions