lib/transportlogger.js
function Transport(settings, levels) {
  settings = settings || {};
  this.levels = levels;

  // Set the base settings
  this.settings = {
    levels: levels,
    timestamp: !!settings.timestamp,
    prependLevel: !!settings.prependLevel,
    colorize: !!settings.colorize,
    name: settings.name
  };

  // Parse the min logging level
  this.settings.minLevel = settings.hasOwnProperty('minLevel') ? settings.minLevel : DEFAULT_MIN_LEVEL;
  if (this.settings.minLevel && getLevelIndex(this.settings.minLevel, levels) === -1) {
    throw new Error('Invalid minimum logging level "' + this.settings.minLevel + '"');
  }

  // Determine the stream
  if (settings.destination) {
    if (typeof settings.destination === 'string' || settings.destination instanceof String) {
      ensurePathExists(path.dirname(settings.destination));
      this.stream = fs.createWriteStream(settings.destination, {
        flags: 'a'
      });
      this.destination = settings.destination;
      if (fs.existsSync(settings.destination)) {
        this.lineCount = fs.readFileSync(settings.destination).toString().split('\n').length;
      }
      if (typeof settings.maxLines != 'undefined') {
        this.maxLines = settings.maxLines;
      }
    } else if (['object', 'function'].indexOf(typeof settings.destination) !== -1 && settings.destination instanceof stream.Writable) {
      this.stream = settings.destination;
    } else {
      throw new Error('Invalid destination specified. A destination must be a string, a writable stream instance, or undefined');
    }
  }

  // Set/create the formatter method
  this.formatter = settings.formatter ? settings.formatter : defaultFormatter;
}
function Transport(settings, levels) {
  settings = settings || {};
  this.levels = levels;

  // Set the base settings
  this.settings = {
    levels: levels,
    timestamp: !!settings.timestamp,
    prependLevel: !!settings.prependLevel,
    colorize: !!settings.colorize,
    name: settings.name
  };

  // Parse the min logging level
  this.settings.minLevel = settings.hasOwnProperty('minLevel') ? settings.minLevel : DEFAULT_MIN_LEVEL;
  if (this.settings.minLevel && getLevelIndex(this.settings.minLevel, levels) === -1) {
    throw new Error('Invalid minimum logging level "' + this.settings.minLevel + '"');
  }

  // Determine the stream
  if (settings.destination) {
    if (typeof settings.destination === 'string' || settings.destination instanceof String) {
      ensurePathExists(path.dirname(settings.destination));
      this.stream = fs.createWriteStream(settings.destination, {
        flags: 'a'
      });
      this.destination = settings.destination;
      if (fs.existsSync(settings.destination)) {
        this.lineCount = fs.readFileSync(settings.destination).toString().split('\n').length;
      }
      if (typeof settings.maxLines != 'undefined') {
        this.maxLines = settings.maxLines;
      }
    } else if (['object', 'function'].indexOf(typeof settings.destination) !== -1 && settings.destination instanceof stream.Writable) {
      this.stream = settings.destination;
    } else {
      throw new Error('Invalid destination specified. A destination must be a string, a writable stream instance, or undefined');
    }
  }

  // Set/create the formatter method
  this.formatter = settings.formatter ? settings.formatter : defaultFormatter;
}
function Transport ( settings , levels ) { settings = settings || { } ; this . levels = levels ; // Set the base settings this . settings = { levels : levels , timestamp : ! ! settings . timestamp , prependLevel : ! ! settings . prependLevel , colorize : ! ! settings . colorize , name : settings . name } ; // Parse the min logging level this . settings . minLevel = settings . hasOwnProperty ( 'minLevel' ) ? settings . minLevel : DEFAULT_MIN_LEVEL ; if ( this . settings . minLevel && getLevelIndex ( this . settings . minLevel , levels ) === - 1 ) { throw new Error ( 'Invalid minimum logging level "' + this . settings . minLevel + '"' ) ; } // Determine the stream if ( settings . destination ) { if ( typeof settings . destination === 'string' || settings . destination instanceof String ) { ensurePathExists ( path . dirname ( settings . destination ) ) ; this . stream = fs . createWriteStream ( settings . destination , { flags : 'a' } ) ; this . destination = settings . destination ; if ( fs . existsSync ( settings . destination ) ) { this . lineCount = fs . readFileSync ( settings . destination ) . toString ( ) . split ( '\n' ) . length ; } if ( typeof settings . maxLines != 'undefined' ) { this . maxLines = settings . maxLines ; } } else if ( [ 'object' , 'function' ] . indexOf ( typeof settings . destination ) !== - 1 && settings . destination instanceof stream . Writable ) { this . stream = settings . destination ; } else { throw new Error ( 'Invalid destination specified. A destination must be a string, a writable stream instance, or undefined' ) ; } } // Set/create the formatter method this . formatter = settings . formatter ? settings . formatter : defaultFormatter ; }
Settings for creating a transport.

@name module:transport-logger.TransportSettings
@type Object
@property {Boolean} [timestamp] Timestamps each log message with a UTC date (default false)
@property {Boolean} [prependLevel] Prepends each log message with the log level (default false)
@property {String} [minLevel] The minimum logging level (default DEFAULT_MIN_LEVEL)
@property {Function} [formatter] A function to format messages with
@property {String | stream.Writable} [destination] The path to the log file
@property {String} [name] The name of the stream
@property {Number} [maxLines] The maximum number of lines to log befor rolling over to a new file. This only
applies to file transports created using a string path for the destination.
Settings for creating a transport .