lib/logger.js
function createLogger(opt_level, opt_dir) {
  var config = getLogConfig(opt_level, opt_dir);
  var transports = getTransports(config);

  // check logdir
  if (!fs.existsSync(config.file.dir)) {
    throw new Error(
      util.format('The logdir does not exist: %s', config.file.dir));
  }

  // create instance
  var logger = new (winston.Logger)({
    transports: [
      new winston.transports.Console(transports.console),
      new winston.transports.File(transports.file)
    ],
    exitOnError: false,
    exceptionHandlers: [
      new winston.transports.File(transports.error)
    ]
  });

  // use syslog's levels
  logger.setLevels(winston.config.syslog.levels);

  // if production env, remove console logger
  if (process.env.NODE_ENV === 'production') {
    logger.remove(winston.transports.Console);
  }

  return logger;
}
function createLogger(opt_level, opt_dir) {
  var config = getLogConfig(opt_level, opt_dir);
  var transports = getTransports(config);

  // check logdir
  if (!fs.existsSync(config.file.dir)) {
    throw new Error(
      util.format('The logdir does not exist: %s', config.file.dir));
  }

  // create instance
  var logger = new (winston.Logger)({
    transports: [
      new winston.transports.Console(transports.console),
      new winston.transports.File(transports.file)
    ],
    exitOnError: false,
    exceptionHandlers: [
      new winston.transports.File(transports.error)
    ]
  });

  // use syslog's levels
  logger.setLevels(winston.config.syslog.levels);

  // if production env, remove console logger
  if (process.env.NODE_ENV === 'production') {
    logger.remove(winston.transports.Console);
  }

  return logger;
}
function createLogger ( opt_level , opt_dir ) { var config = getLogConfig ( opt_level , opt_dir ) ; var transports = getTransports ( config ) ; // check logdir if ( ! fs . existsSync ( config . file . dir ) ) { throw new Error ( util . format ( 'The logdir does not exist: %s' , config . file . dir ) ) ; } // create instance var logger = new ( winston . Logger ) ( { transports : [ new winston . transports . Console ( transports . console ) , new winston . transports . File ( transports . file ) ] , exitOnError : false , exceptionHandlers : [ new winston . transports . File ( transports . error ) ] } ) ; // use syslog's levels logger . setLevels ( winston . config . syslog . levels ) ; // if production env, remove console logger if ( process . env . NODE_ENV === 'production' ) { logger . remove ( winston . transports . Console ) ; } return logger ; }
Instantiate winston logger.

@param {string=} opt_level .
@param {string=} opt_dir .
@return {winston.Logger} .
Instantiate winston logger .