index.js
function genericLog(logger, moduletag, logLevel='info'){
  const isDebug = logLevel==='debug'
  const level = isDebug
    ? 'info'
    : logLevel
  const levelLogger = logger[level]
  const active = isDebug
    ? enabled(moduletag)
    : true

  /**
   * tagged Logger
   * @function taggedLog
   * @param {...string} tags Optional message tags
   */
  function taggedLog(...tags) {
    const tag = normalizeDefaults(tags)
    /**
     * message Logger
     * @function messageLog
     * @template T
     * @param {...T} messages message
     * @returns {T}
     */
    function messageLog(...messages) {
      if (active) {
        const protectedMessage = messageArrayProtect(messages)
        levelLogger(tag, ...protectedMessage)
      }
      return messages[0]
    }
    return messageLog
  }
  /**
   * Array logge Prinst every value on separated line
   * @function mapLog
   * @param {...string} tags Optional message tags
   */
  function mapLog(...tags) {
    /**
     * Array logge Prinst every value on separated line
     * @function printArray
     * @param {Array} message Printed list
     * @returns {Array}
     */
    function printArray(message) {
      if (active) {
        arrayCheck(message)
        const tag = normalizeDefaults(tags)
        //count length + 2. Also handles edge case with objects without 'length' field
        const spaceLn = P(
          length,
          defaultTo(0),
          add(2) )
        const ln = sum( map( spaceLn, tags ) )
        const spaces = new Array(ln)
          .fill(' ')
          .join('')

        const getFormatted = num => chalk.green(`<${num}>`)
        levelLogger( tag, getFormatted(0), head( message ) )
        const printTail = (e, i) => levelLogger(spaces, getFormatted(i+1), e)

        P(
          tail,
          indexedMap(printTail)
        )(message)
      }
      return message
    }
    return printArray
  }
  taggedLog.map = mapLog
  return taggedLog
}
function genericLog(logger, moduletag, logLevel='info'){
  const isDebug = logLevel==='debug'
  const level = isDebug
    ? 'info'
    : logLevel
  const levelLogger = logger[level]
  const active = isDebug
    ? enabled(moduletag)
    : true

  /**
   * tagged Logger
   * @function taggedLog
   * @param {...string} tags Optional message tags
   */
  function taggedLog(...tags) {
    const tag = normalizeDefaults(tags)
    /**
     * message Logger
     * @function messageLog
     * @template T
     * @param {...T} messages message
     * @returns {T}
     */
    function messageLog(...messages) {
      if (active) {
        const protectedMessage = messageArrayProtect(messages)
        levelLogger(tag, ...protectedMessage)
      }
      return messages[0]
    }
    return messageLog
  }
  /**
   * Array logge Prinst every value on separated line
   * @function mapLog
   * @param {...string} tags Optional message tags
   */
  function mapLog(...tags) {
    /**
     * Array logge Prinst every value on separated line
     * @function printArray
     * @param {Array} message Printed list
     * @returns {Array}
     */
    function printArray(message) {
      if (active) {
        arrayCheck(message)
        const tag = normalizeDefaults(tags)
        //count length + 2. Also handles edge case with objects without 'length' field
        const spaceLn = P(
          length,
          defaultTo(0),
          add(2) )
        const ln = sum( map( spaceLn, tags ) )
        const spaces = new Array(ln)
          .fill(' ')
          .join('')

        const getFormatted = num => chalk.green(`<${num}>`)
        levelLogger( tag, getFormatted(0), head( message ) )
        const printTail = (e, i) => levelLogger(spaces, getFormatted(i+1), e)

        P(
          tail,
          indexedMap(printTail)
        )(message)
      }
      return message
    }
    return printArray
  }
  taggedLog.map = mapLog
  return taggedLog
}
function genericLog ( logger , moduletag , logLevel = 'info' ) { const isDebug = logLevel === 'debug' const level = isDebug ? 'info' : logLevel const levelLogger = logger [ level ] const active = isDebug ? enabled ( moduletag ) : true /**
   * tagged Logger
   * @function taggedLog
   * @param {...string} tags Optional message tags
   */ function taggedLog ( ... tags ) { const tag = normalizeDefaults ( tags ) /**
     * message Logger
     * @function messageLog
     * @template T
     * @param {...T} messages message
     * @returns {T}
     */ function messageLog ( ... messages ) { if ( active ) { const protectedMessage = messageArrayProtect ( messages ) levelLogger ( tag , ... protectedMessage ) } return messages [ 0 ] } return messageLog } /**
   * Array logge Prinst every value on separated line
   * @function mapLog
   * @param {...string} tags Optional message tags
   */ function mapLog ( ... tags ) { /**
     * Array logge Prinst every value on separated line
     * @function printArray
     * @param {Array} message Printed list
     * @returns {Array}
     */ function printArray ( message ) { if ( active ) { arrayCheck ( message ) const tag = normalizeDefaults ( tags ) //count length + 2. Also handles edge case with objects without 'length' field const spaceLn = P ( length , defaultTo ( 0 ) , add ( 2 ) ) const ln = sum ( map ( spaceLn , tags ) ) const spaces = new Array ( ln ) . fill ( ' ' ) . join ( '' ) const getFormatted = num => chalk . green ( ` ${ num } ` ) levelLogger ( tag , getFormatted ( 0 ) , head ( message ) ) const printTail = ( e , i ) => levelLogger ( spaces , getFormatted ( i + 1 ) , e ) P ( tail , indexedMap ( printTail ) ) ( message ) } return message } return printArray } taggedLog . map = mapLog return taggedLog }
Allow to select log level
@function genericLog
@param {LoggerInstance} logger Winston logger instance
@param {string} moduletag Module tag name
@param {string} logLevel Log level
Allow to select log level