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

Feature request: categories #12

Open
d9k opened this issue Feb 26, 2018 · 2 comments
Open

Feature request: categories #12

d9k opened this issue Feb 26, 2018 · 2 comments

Comments

@d9k
Copy link

d9k commented Feb 26, 2018

Feature request: categories and filter by categories.

Category must be a new non-required string parameter for log function .

@moteus
Copy link
Owner

moteus commented Feb 26, 2018

I do not think I like this idea.

When I create this library I think about it as a low level
library. And to build complex loggers just need one more
level which will build loggers based on configuration files
like this.

local log = Logger[category]
log.error('message')

-- or even use `log` to build/find new loggers
local db_log = log.database

Where Logger will build new loggers by some config.

-- Config at first have to define all writers.
-- It is important because some writers create
-- worker threads to  do IO in background
writers = {
  file1 = { type = 'file' ... },
  file2 = { type = 'file' ... }.
  server1 = {type = 'net.udp'},
  email = {type = 'smtp'},
}

-- Then define loggers based on existed writers.
loggers = {
  category1 = {
    writers = {
         {writers.file1, writers.server1},
         alert = writers.email,
    }
    -- may be other settings
  },
  category1 = {
    writers = {
         {writers.file2, writers.server1},
         alert = writers.email,
    }
  },
}

@d9k
Copy link
Author

d9k commented Feb 27, 2018

thx, @moteus, I was intending to overcome the lack of categories exactly the same way you're suggesting!

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

2 participants