src/index.js
function createLogger (writables, prefix, dateFormat) {
  if (!Array.isArray(writables)) writables = [ writables ]

  writables = writables.filter(w => isDefined(w) && isFunction(w.write))

  debug(`There are ${writables.length} writables for this logger`)

  let pre = `[${prefix}]`
  // default timestamp format
  if (dateFormat === true) dateFormat = 'YYYY-MM-DD HH:mm:ss'
  if (typeof dateFormat === 'string') {
    pre += ` ${moment().format(dateFormat)}`
  }

  return msg => {
    writables.forEach(w => w.write(`${pre} ${msg}\n`))
  }
}
function createLogger (writables, prefix, dateFormat) {
  if (!Array.isArray(writables)) writables = [ writables ]

  writables = writables.filter(w => isDefined(w) && isFunction(w.write))

  debug(`There are ${writables.length} writables for this logger`)

  let pre = `[${prefix}]`
  // default timestamp format
  if (dateFormat === true) dateFormat = 'YYYY-MM-DD HH:mm:ss'
  if (typeof dateFormat === 'string') {
    pre += ` ${moment().format(dateFormat)}`
  }

  return msg => {
    writables.forEach(w => w.write(`${pre} ${msg}\n`))
  }
}
function createLogger ( writables , prefix , dateFormat ) { if ( ! Array . isArray ( writables ) ) writables = [ writables ] writables = writables . filter ( w => isDefined ( w ) && isFunction ( w . write ) ) debug ( ` ${ writables . length } ` ) let pre = ` ${ prefix } ` // default timestamp format if ( dateFormat === true ) dateFormat = 'YYYY-MM-DD HH:mm:ss' if ( typeof dateFormat === 'string' ) { pre += ` ${ moment ( ) . format ( dateFormat ) } ` } return msg => { writables . forEach ( w => w . write ( ` ${ pre } ${ msg } \n ` ) ) } }
Main method for create logger. The logger is just a function to recieve
the record and write to a stream.

@param  {Writable}       writable    A writable stream for logging
@param  {string}         prefix      The prefix to write
@param  {string | bool}  date        The date format
@return {function} A function use like `console.log`
Main method for create logger . The logger is just a function to recieve the record and write to a stream .