Esempio n. 1
0
function Bunyan2Loggly(logglyConfig, bufferLength, bufferTimeout, callback) {
    if (!logglyConfig || !logglyConfig.token || !logglyConfig.subdomain) {
        throw new Error('bunyan-loggly requires a config object with token and subdomain');
    }

    logglyConfig.json = true;
    logglyConfig.isBulk = true;

    this.logglyClient = loggly.createClient(logglyConfig);

    this._buffer = [];
    this.bufferLength = bufferLength || 1;
    this.bufferTimeout = bufferTimeout;
    this.callback = callback || noop;
}
Esempio n. 2
0
function Bunyan2Loggly(logglyConfig, bufferLength, bufferTimeout, callback) {
    if (!logglyConfig || !logglyConfig.token || !logglyConfig.subdomain) {
        throw new Error('bunyan-loggly requires a config object with token and subdomain');
    }

    this.callback = callback || noop;
    this.bufferLength = bufferLength || 1;
    this.bufferTimeout = bufferTimeout || 30 * 1000;

    logglyConfig.json = logglyConfig.json !== false;
    logglyConfig.isBulk = logglyConfig.isBulk !== false;

    if (logglyConfig.isBulk) {
        logglyConfig.bufferOptions = {
            size: this.bufferLength,
            retriesInMilliSeconds: this.bufferTimeout,
        };
    }

    this.logglyClient = loggly.createClient(logglyConfig);
}
var Loggly = exports.Loggly = function (options) {
  options = options || {};

  //
  // Small amount of backwards compatibility with 0.x.x
  //
  if (options.inputToken && !options.token) {
    options.token = options.inputToken;
  }

  Transport.call(this, options);
  if (!options.subdomain) {
    throw new Error('Loggly Subdomain is required');
  }
  else if (!options || !options.token) {
    throw new Error('Loggly Customer token is required.');
  }

  this.name   = 'loggly';
  var tags = options.tags || options.tag || options.id;
  if (tags && !Array.isArray(tags)) {
    tags = [tags];
  }

  this.client = loggly.createClient({
    subdomain: options.subdomain,
    auth: options.auth || null,
    json: options.json || false, //TODO: should be false
    proxy: options.proxy || null,
    token: options.token,
    tags: tags,
    isBulk: options.isBulk || false,
    bufferOptions: options.bufferOptions || {size: 500, retriesInMilliSeconds: 30 * 1000},
    networkErrorsOnConsole: options.networkErrorsOnConsole || false
  });

  this.timestamp = options.timestamp === false ? false : true;
  this.stripColors = options.stripColors || false;
};