lib/index.js
function Formatter(options) {
  function format(entry) {  // eslint-disable-line
    return stringify(makeEvent(entry, format.hostname));
  }

  if (!options) {
    options = { };
  }

  Object.setPrototypeOf(format, Formatter.prototype);
  format.hostname = options.hostname || os.hostname();
  return format;
}
function Formatter(options) {
  function format(entry) {  // eslint-disable-line
    return stringify(makeEvent(entry, format.hostname));
  }

  if (!options) {
    options = { };
  }

  Object.setPrototypeOf(format, Formatter.prototype);
  format.hostname = options.hostname || os.hostname();
  return format;
}
function Formatter ( options ) { function format ( entry ) { // eslint-disable-line return stringify ( makeEvent ( entry , format . hostname ) ) ; } if ( ! options ) { options = { } ; } Object . setPrototypeOf ( format , Formatter . prototype ) ; format . hostname = options . hostname || os . hostname ( ) ; return format ; }
The Formatter type implements a winston log formatter that produces messages
compatible with ecs-logs.

The object returned when instantiating the Formatter type is callable. When
called, it expects a log entry object.

@example
var ecslogs = require('ecs-logs-js');
var winston = require('winston');

// Instantiate an ecs-logs compatible winston logger with ecslogs.Formatter
var logger = new winston.Logger({
transports: [
new winston.transports.Console({
timestamp: Date.now,
formatter: new ecslogs.Formatter()
})
]
});

@example
var ecslogs = require('ecs-logs-js');
var formatter = new ecslogs.Formatter();

// Returns a serialized log message compatible with ecs-logs.
var s = formatter({
message: 'the log message',
level: 'info',
meta: {
'User-Agent': 'node'
}
});

@param {Object} [options] The configuration object for the new formatter

@param {string} [options.hostname] The hostname to report in the log
messages, defaults to the value returned by os.hostname()

@return {string} When a formatter instance is called it accepts a log entry
as argument and returns a JSON representation of the entry in a format
compatible with ecs-logs
The Formatter type implements a winston log formatter that produces messages compatible with ecs - logs .