lib/transportlogger.js
function Logger(transports, settings) {
  var i, len,
      transport,
      levels,
      transportInstances = [],
      names = {};

  // Normalize the inputs
  if (!transports) {
    transports = [{}];
  } else if (!Array.isArray(transports)) {
    transports = [transports];
  }
  settings = settings || {};
  levels = settings.levels || DEFAULT_LEVELS;

  // Create the transports
  for (i = 0, len = transports.length; i < len; i++) {
    transport = transports[i];
    if (transport.name) {
      names[transport.name] = 1;
    }
    transportInstances.push(new Transport(transport, levels));
  }

  // Create the log methods
  levels.forEach(function (level) {
    this[level.id] = function log() {
      var i, ilen, j, jlen,
          p,
          messages = Array.prototype.slice.call(arguments, 0),
          transportMessages = new Array(messages.length),
          areNamed = new Array(messages.length),
          areAnyNamed = false,
          message,
          isNamed;
      for (i = 0, ilen = messages.length; i < ilen; i++) {
        message = messages[i];
        isNamed = false;
        if (typeof message === 'object') {
          isNamed = true;
          for (p in message) {
            if (message.hasOwnProperty(p)) {
              if (!names[p]) {
                isNamed = false;
              }
            }
          }
        }
        areNamed[i] = isNamed;
        areAnyNamed = areAnyNamed || isNamed;
      }
      for (i = 0, ilen = transportInstances.length; i < ilen; i++) {
        if (areAnyNamed) {
          for (j = 0, jlen = messages.length; j < jlen; j++) {
            if (areNamed[j]) {
              transportMessages[j] = messages[j][transportInstances[i].settings.name];
            } else {
              transportMessages[j] = messages[j];
            }
          }
          transportInstances[i].log(transportMessages, level);
        } else {
          transportInstances[i].log(messages, level);
        }
      }
    };
  }.bind(this));
}
function Logger(transports, settings) {
  var i, len,
      transport,
      levels,
      transportInstances = [],
      names = {};

  // Normalize the inputs
  if (!transports) {
    transports = [{}];
  } else if (!Array.isArray(transports)) {
    transports = [transports];
  }
  settings = settings || {};
  levels = settings.levels || DEFAULT_LEVELS;

  // Create the transports
  for (i = 0, len = transports.length; i < len; i++) {
    transport = transports[i];
    if (transport.name) {
      names[transport.name] = 1;
    }
    transportInstances.push(new Transport(transport, levels));
  }

  // Create the log methods
  levels.forEach(function (level) {
    this[level.id] = function log() {
      var i, ilen, j, jlen,
          p,
          messages = Array.prototype.slice.call(arguments, 0),
          transportMessages = new Array(messages.length),
          areNamed = new Array(messages.length),
          areAnyNamed = false,
          message,
          isNamed;
      for (i = 0, ilen = messages.length; i < ilen; i++) {
        message = messages[i];
        isNamed = false;
        if (typeof message === 'object') {
          isNamed = true;
          for (p in message) {
            if (message.hasOwnProperty(p)) {
              if (!names[p]) {
                isNamed = false;
              }
            }
          }
        }
        areNamed[i] = isNamed;
        areAnyNamed = areAnyNamed || isNamed;
      }
      for (i = 0, ilen = transportInstances.length; i < ilen; i++) {
        if (areAnyNamed) {
          for (j = 0, jlen = messages.length; j < jlen; j++) {
            if (areNamed[j]) {
              transportMessages[j] = messages[j][transportInstances[i].settings.name];
            } else {
              transportMessages[j] = messages[j];
            }
          }
          transportInstances[i].log(transportMessages, level);
        } else {
          transportInstances[i].log(messages, level);
        }
      }
    };
  }.bind(this));
}
function Logger ( transports , settings ) { var i , len , transport , levels , transportInstances = [ ] , names = { } ; // Normalize the inputs if ( ! transports ) { transports = [ { } ] ; } else if ( ! Array . isArray ( transports ) ) { transports = [ transports ] ; } settings = settings || { } ; levels = settings . levels || DEFAULT_LEVELS ; // Create the transports for ( i = 0 , len = transports . length ; i < len ; i ++ ) { transport = transports [ i ] ; if ( transport . name ) { names [ transport . name ] = 1 ; } transportInstances . push ( new Transport ( transport , levels ) ) ; } // Create the log methods levels . forEach ( function ( level ) { this [ level . id ] = function log ( ) { var i , ilen , j , jlen , p , messages = Array . prototype . slice . call ( arguments , 0 ) , transportMessages = new Array ( messages . length ) , areNamed = new Array ( messages . length ) , areAnyNamed = false , message , isNamed ; for ( i = 0 , ilen = messages . length ; i < ilen ; i ++ ) { message = messages [ i ] ; isNamed = false ; if ( typeof message === 'object' ) { isNamed = true ; for ( p in message ) { if ( message . hasOwnProperty ( p ) ) { if ( ! names [ p ] ) { isNamed = false ; } } } } areNamed [ i ] = isNamed ; areAnyNamed = areAnyNamed || isNamed ; } for ( i = 0 , ilen = transportInstances . length ; i < ilen ; i ++ ) { if ( areAnyNamed ) { for ( j = 0 , jlen = messages . length ; j < jlen ; j ++ ) { if ( areNamed [ j ] ) { transportMessages [ j ] = messages [ j ] [ transportInstances [ i ] . settings . name ] ; } else { transportMessages [ j ] = messages [ j ] ; } } transportInstances [ i ] . log ( transportMessages , level ) ; } else { transportInstances [ i ] . log ( messages , level ) ; } } } ; } . bind ( this ) ) ; }
The global settings for the logger that applies to all transports

@name module:transport-logger.GlobalSettings
@type Object
@property {Object} [levels] The log levels
@property {String} <log-level> The key specifies the log level, and the value specifies the color. Colors are one of
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', and 'normal'
 
Creates a new logger instance

@name module:transport-logger.Logger
@constructor
@param {TransportSettings | TransportSettings[]} [transports] The transports to use
@param {GlobalSettings} [settings] The global settings
The global settings for the logger that applies to all transports