index.js
function (config) {
  winston.Transport.call(this, config);

  /** @property {string} name - the name of the transport */
  this.name = 'SplunkStreamEvent';

  /** @property {string} level - the minimum level to log */
  this.level = config.level || 'info';

  // Verify that we actually have a splunk object and a token
  if (!config.splunk || !config.splunk.token) {
    throw new Error('Invalid Configuration: options.splunk is invalid');
  }

  // If source/sourcetype are mentioned in the splunk object, then store the
  // defaults in this and delete from the splunk object
  this.defaultMetadata = {
    source: 'winston',
    sourcetype: 'winston-splunk-logger'
  };
  if (config.splunk.source) {
    this.defaultMetadata.source = config.splunk.source;
    delete config.splunk.source;
  }
  if (config.splunk.sourcetype) {
    this.defaultMetadata.sourcetype = config.splunk.sourcetype;
    delete config.splunk.sourcetype;
  }

  // This gets around a problem with setting maxBatchCount
  config.splunk.maxBatchCount = 1;
  this.server = new SplunkLogger(config.splunk);

  // Override the default event formatter
  if (config.splunk.eventFormatter) {
    this.server.eventFormatter = config.splunk.eventFormatter;
  }
}
function (config) {
  winston.Transport.call(this, config);

  /** @property {string} name - the name of the transport */
  this.name = 'SplunkStreamEvent';

  /** @property {string} level - the minimum level to log */
  this.level = config.level || 'info';

  // Verify that we actually have a splunk object and a token
  if (!config.splunk || !config.splunk.token) {
    throw new Error('Invalid Configuration: options.splunk is invalid');
  }

  // If source/sourcetype are mentioned in the splunk object, then store the
  // defaults in this and delete from the splunk object
  this.defaultMetadata = {
    source: 'winston',
    sourcetype: 'winston-splunk-logger'
  };
  if (config.splunk.source) {
    this.defaultMetadata.source = config.splunk.source;
    delete config.splunk.source;
  }
  if (config.splunk.sourcetype) {
    this.defaultMetadata.sourcetype = config.splunk.sourcetype;
    delete config.splunk.sourcetype;
  }

  // This gets around a problem with setting maxBatchCount
  config.splunk.maxBatchCount = 1;
  this.server = new SplunkLogger(config.splunk);

  // Override the default event formatter
  if (config.splunk.eventFormatter) {
    this.server.eventFormatter = config.splunk.eventFormatter;
  }
}
function ( config ) { winston . Transport . call ( this , config ) ; /** @property {string} name - the name of the transport */ this . name = 'SplunkStreamEvent' ; /** @property {string} level - the minimum level to log */ this . level = config . level || 'info' ; // Verify that we actually have a splunk object and a token if ( ! config . splunk || ! config . splunk . token ) { throw new Error ( 'Invalid Configuration: options.splunk is invalid' ) ; } // If source/sourcetype are mentioned in the splunk object, then store the // defaults in this and delete from the splunk object this . defaultMetadata = { source : 'winston' , sourcetype : 'winston-splunk-logger' } ; if ( config . splunk . source ) { this . defaultMetadata . source = config . splunk . source ; delete config . splunk . source ; } if ( config . splunk . sourcetype ) { this . defaultMetadata . sourcetype = config . splunk . sourcetype ; delete config . splunk . sourcetype ; } // This gets around a problem with setting maxBatchCount config . splunk . maxBatchCount = 1 ; this . server = new SplunkLogger ( config . splunk ) ; // Override the default event formatter if ( config . splunk . eventFormatter ) { this . server . eventFormatter = config . splunk . eventFormatter ; } }
A class that implements a Winston transport provider for Splunk HTTP Event Collector

@param {object} config - Configuration settings for a new Winston transport
@param {string} [config.level=info] - the minimum level to log
@param {object} config.splunk - the Splunk Logger settings
@param {string} config.splunk.token - the Splunk HTTP Event Collector token
@param {string} [config.splunk.source=winston] - the source for the events sent to Splunk
@param {string} [config.splunk.sourcetype=winston-splunk-logger] - the sourcetype for the events sent to Splunk
@param {string} [config.splunk.host=localhost] - the Splunk HTTP Event Collector host
@param {number} [config.splunk.maxRetries=0] - How many times to retry the splunk logger
@param {number} [config.splunk.port=8088] - the Splunk HTTP Event Collector port
@param {string} [config.splunk.path=/services/collector/event/1.0] - URL path to use
@param {string} [config.splunk.protocol=https] - the protocol to use
@param {string} [config.splunk.url] - URL string to pass to url.parse for the information
@param {function} [config.splunk.eventFormatter] - Formats events, returning an event as a string, <code>function(message, severity)</code>
@param {string} [config.level=info] - Logging level to use, will show up as the <code>severity</code> field of an event, see
[SplunkLogger.levels]{@link SplunkLogger#levels} for common levels.
@param {number} [config.batchInterval=0] - Automatically flush events after this many milliseconds.
When set to a non-positive value, events will be sent one by one. This setting is ignored when non-positive.
@param {number} [config.maxBatchSize=0] - Automatically flush events after the size of queued
events exceeds this many bytes. This setting is ignored when non-positive.
@param {number} [config.maxBatchCount=1] - Automatically flush events after this many
events have been queued. Defaults to flush immediately on sending an event. This setting is ignored when non-positive.

@constructor
A class that implements a Winston transport provider for Splunk HTTP Event Collector