index.js
function createLogger (config) {
  config = config || {}
  let level
  if (process.env.KOOP_LOG_LEVEL) {
    level = process.env.KOOP_LOG_LEVEL
  } else if (process.env.NODE_ENV === 'production') {
    level = 'info'
  } else {
    level = 'debug'
  }

  if (!config.logfile) {
    // no logfile defined, log to STDOUT an STDERRv
    const debugConsole = new winston.transports.Console({
      colorize: process.env.NODE_ENV === 'production',
      level,
      stringify: true,
      json: true
    })
    return new winston.Logger({ transports: [debugConsole] })
  }

  // we need a dir to do log rotation so we get the dir from the file
  const logpath = path.dirname(config.logfile)
  const logAll = new winston.transports.File({
    filename: config.logfile,
    name: 'log.all',
    dirname: logpath,
    colorize: true,
    json: false,
    level,
    formatter: formatter
  })
  const logError = new winston.transports.File({
    filename: config.logfile.replace('.log', '.error.log'),
    name: 'log.error',
    dirname: logpath,
    colorize: true,
    json: false,
    level: 'error',
    formatter: formatter
  })

  // always log errors
  const transports = [logError]
  // only log everthing if debug mode is on
  if (process.env['LOG_LEVEL'] === 'debug') {
    transports.push(logAll)
  }

  return new winston.Logger({ transports })
}
function createLogger (config) {
  config = config || {}
  let level
  if (process.env.KOOP_LOG_LEVEL) {
    level = process.env.KOOP_LOG_LEVEL
  } else if (process.env.NODE_ENV === 'production') {
    level = 'info'
  } else {
    level = 'debug'
  }

  if (!config.logfile) {
    // no logfile defined, log to STDOUT an STDERRv
    const debugConsole = new winston.transports.Console({
      colorize: process.env.NODE_ENV === 'production',
      level,
      stringify: true,
      json: true
    })
    return new winston.Logger({ transports: [debugConsole] })
  }

  // we need a dir to do log rotation so we get the dir from the file
  const logpath = path.dirname(config.logfile)
  const logAll = new winston.transports.File({
    filename: config.logfile,
    name: 'log.all',
    dirname: logpath,
    colorize: true,
    json: false,
    level,
    formatter: formatter
  })
  const logError = new winston.transports.File({
    filename: config.logfile.replace('.log', '.error.log'),
    name: 'log.error',
    dirname: logpath,
    colorize: true,
    json: false,
    level: 'error',
    formatter: formatter
  })

  // always log errors
  const transports = [logError]
  // only log everthing if debug mode is on
  if (process.env['LOG_LEVEL'] === 'debug') {
    transports.push(logAll)
  }

  return new winston.Logger({ transports })
}
function createLogger ( config ) { config = config || { } let level if ( process . env . KOOP_LOG_LEVEL ) { level = process . env . KOOP_LOG_LEVEL } else if ( process . env . NODE_ENV === 'production' ) { level = 'info' } else { level = 'debug' } if ( ! config . logfile ) { // no logfile defined, log to STDOUT an STDERRv const debugConsole = new winston . transports . Console ( { colorize : process . env . NODE_ENV === 'production' , level , stringify : true , json : true } ) return new winston . Logger ( { transports : [ debugConsole ] } ) } // we need a dir to do log rotation so we get the dir from the file const logpath = path . dirname ( config . logfile ) const logAll = new winston . transports . File ( { filename : config . logfile , name : 'log.all' , dirname : logpath , colorize : true , json : false , level , formatter : formatter } ) const logError = new winston . transports . File ( { filename : config . logfile . replace ( '.log' , '.error.log' ) , name : 'log.error' , dirname : logpath , colorize : true , json : false , level : 'error' , formatter : formatter } ) // always log errors const transports = [ logError ] // only log everthing if debug mode is on if ( process . env [ 'LOG_LEVEL' ] === 'debug' ) { transports . push ( logAll ) } return new winston . Logger ( { transports } ) }
creates new custom winston logger

@param {object} config - koop configuration
@return {Logger} custom logger instance
creates new custom winston logger