lib/formatters.js
function formatDevTrace(level, context, message, args, err) {
  var str,
      mainMessage = util.format.apply(global, [message].concat(args)),
      printStack = API.stacktracesWith.indexOf(level) > -1,
      errCommomMessage = err && (err.name + ': ' + err.message),
      isErrorLoggingWithoutMessage = mainMessage === errCommomMessage;

  switch (level) {
    case 'DEBUG':
      str = colors.grey(level);
      break;
    case 'INFO':
      str = colors.blue(level) + ' '; // Pad to 5 chars
      break;
    case 'WARN':
      str = colors.yellow(level) + ' '; // Pad to 5 chars
      break;
    case 'ERROR':
      str = colors.red(level);
      break;
    case 'FATAL':
      str = colors.red.bold(level);
      break;
  }
  str += ' ' + mainMessage;

  if (isErrorLoggingWithoutMessage) {
    str += colorize(colors.gray, serializeErr(err).toString(printStack).substr(mainMessage.length));
  } else if (err) {
    str += '\n' + colorize(colors.gray, serializeErr(err).toString(printStack));
  }

  var localContext = _.omit(context, formatDevTrace.omit);
  str += Object.keys(localContext).length ?
      ' ' + colorize(colors.gray, util.inspect(localContext)) :
      '';

  // pad all subsequent lines with as much spaces as "DEBUG " or "INFO  " have
  return str.replace(new RegExp('\r?\n','g'), '\n      ');
}
function formatDevTrace(level, context, message, args, err) {
  var str,
      mainMessage = util.format.apply(global, [message].concat(args)),
      printStack = API.stacktracesWith.indexOf(level) > -1,
      errCommomMessage = err && (err.name + ': ' + err.message),
      isErrorLoggingWithoutMessage = mainMessage === errCommomMessage;

  switch (level) {
    case 'DEBUG':
      str = colors.grey(level);
      break;
    case 'INFO':
      str = colors.blue(level) + ' '; // Pad to 5 chars
      break;
    case 'WARN':
      str = colors.yellow(level) + ' '; // Pad to 5 chars
      break;
    case 'ERROR':
      str = colors.red(level);
      break;
    case 'FATAL':
      str = colors.red.bold(level);
      break;
  }
  str += ' ' + mainMessage;

  if (isErrorLoggingWithoutMessage) {
    str += colorize(colors.gray, serializeErr(err).toString(printStack).substr(mainMessage.length));
  } else if (err) {
    str += '\n' + colorize(colors.gray, serializeErr(err).toString(printStack));
  }

  var localContext = _.omit(context, formatDevTrace.omit);
  str += Object.keys(localContext).length ?
      ' ' + colorize(colors.gray, util.inspect(localContext)) :
      '';

  // pad all subsequent lines with as much spaces as "DEBUG " or "INFO  " have
  return str.replace(new RegExp('\r?\n','g'), '\n      ');
}
function formatDevTrace ( level , context , message , args , err ) { var str , mainMessage = util . format . apply ( global , [ message ] . concat ( args ) ) , printStack = API . stacktracesWith . indexOf ( level ) > - 1 , errCommomMessage = err && ( err . name + ': ' + err . message ) , isErrorLoggingWithoutMessage = mainMessage === errCommomMessage ; switch ( level ) { case 'DEBUG' : str = colors . grey ( level ) ; break ; case 'INFO' : str = colors . blue ( level ) + ' ' ; // Pad to 5 chars break ; case 'WARN' : str = colors . yellow ( level ) + ' ' ; // Pad to 5 chars break ; case 'ERROR' : str = colors . red ( level ) ; break ; case 'FATAL' : str = colors . red . bold ( level ) ; break ; } str += ' ' + mainMessage ; if ( isErrorLoggingWithoutMessage ) { str += colorize ( colors . gray , serializeErr ( err ) . toString ( printStack ) . substr ( mainMessage . length ) ) ; } else if ( err ) { str += '\n' + colorize ( colors . gray , serializeErr ( err ) . toString ( printStack ) ) ; } var localContext = _ . omit ( context , formatDevTrace . omit ) ; str += Object . keys ( localContext ) . length ? ' ' + colorize ( colors . gray , util . inspect ( localContext ) ) : '' ; // pad all subsequent lines with as much spaces as "DEBUG " or "INFO  " have return str . replace ( new RegExp ( '\r?\n' , 'g' ) , '\n      ' ) ; }
Formats a trace message with some nice TTY colors

@param {String} level One of the following values
['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL']
@param {Object} context Additional information to add to the trace
@param {String} message The main message to be added to the trace
@param {Array} args More arguments provided to the log function
@param {Error|undefined} err A cause error used to log extra information

@return {String} The trace formatted
Formats a trace message with some nice TTY colors