SHARE
TWEET

Untitled

a guest Oct 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # usage: LOG_LEVEL=debug node convict.js
  2.  
  3. var winston = require('winston');
  4. var convict = require('convict');
  5. var config = convict({
  6.   log: {
  7.     level: {
  8.       doc: 'The winston log level',
  9.       format: 'String',
  10.       default: 'INFO',
  11.       env: 'LOG_LEVEL'
  12.     }
  13.   }
  14. };
  15. config.validate({allowed: 'strict'});
  16. module.exports = config;
  17.  
  18. const logger = winston.createLogger({
  19.   level: config.get("log.level"),
  20.   transports: [
  21.     new winston.transports.Console()
  22.   ]
  23. });
RAW Paste Data
Top