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

Feat: Allow log.categories configuration #151

Open
klouvas opened this issue May 29, 2020 · 3 comments
Open

Feat: Allow log.categories configuration #151

klouvas opened this issue May 29, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@klouvas
Copy link
Contributor

klouvas commented May 29, 2020

Use case:
Enable specific logger category to output debug logs in production for debugging instead of enabling debug level logs for the whole application.

Usage example:

// services/serviceA.js
const logger = require('@workablehr/orka').getLogger('serviceA');

function serviceFn(){
  logger.debug('start');
  // doSomething
  logger.debug('end');
}
module.exports = serviceFn;

// config/env/staging.json
"log": {
  "level": "info",
  "categories": {
  "serviceA": {
    "appenders": ['json'],
     "level": "debug"
  }
}

What should be done:

@klouvas klouvas added the enhancement New feature or request label May 29, 2020
@klouvas klouvas changed the title Allow log.categories configuration Feat: Allow log.categories configuration May 29, 2020
@SokratisVidros
Copy link

Log level is a well used strategy. TBH I really like this approach https://www.npmjs.com/package/debug. It seems more hackable in production.

@nikostoulas
Copy link
Contributor

nikostoulas commented May 29, 2020

@SokratisVidros @klouvas Note that require('debug') is a core Nodejs module. There is no library needed.
Actually it is not a core module but most modules already have it. So almost in any app it is already installed.

@klouvas Your suggestion would be a very nice to have. Ideally since log4js supports subcategories (eg if you have a logger: 'db.user.transaction' you could set different level of logging for all db.* loggers), you would set an env eg LOG_CATEGORY_DB=debug and you would be good to go.
I think the effort to support sth like this would be significant (You need extra code in apps too to include in config all possible categories). The alternative suggested by @SokratisVidros is very easy to include it in any app.
I would use 'debug' and leave this as an open issue in orka for whenever we have the time to see it.

@klouvas
Copy link
Contributor Author

klouvas commented May 29, 2020

i thought that debug had only enable/disable capabilities. I have no strong feelings about any of this approaches. Ideally i would prefer to use the approach already used by most of the company's teams.

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

No branches or pull requests

3 participants