<commit_before>
var loggly = require('loggly'),
	util = require('util');

function Bunyan2Loggly (logglyConfig, buffer) {

	this.logglyConfig = logglyConfig || {};

	// define the log as being json (because bunyan is a json logger)
	this.logglyConfig.json = true;

	// define the buffer count, unless one has already been defined
	this.buffer = buffer || 1;
	this._buffer = [];

	// add the https tag by default, just to make the loggly source setup work as expect
	this.logglyConfig.tags = this.logglyConfig.tags || [];
	this.logglyConfig.tags.push('https');

	// create the client
	this.client = loggly.createClient(logglyConfig);

}

Bunyan2Loggly.prototype.write = function(rec) {

	if (typeof rec !== 'object' && !Array.isArray(rec)) {
		throw new Error('bunyan-loggly requires a raw stream. Please define the type as raw when setting up the bunyan stream.');
	}

	if (typeof rec === 'object') {

		// loggly prefers timestamp over time
		if (rec.time !== undefined) {
			rec.timestamp = rec.time;
			delete rec.time;
		}

	}

	// write to our array buffer
	this._buffer.push(rec);

	// check the buffer, we may or may not need to send to loggly
	this.checkBuffer();

};

Bunyan2Loggly.prototype.checkBuffer = function () {

	if (this._buffer.length < this.buffer) {
		return;
	}

	// duplicate the array, because it could be modified before our HTTP call succeeds
	var content = this._buffer.slice();
	this._buffer = [];

	// log multiple (or single) requests with loggly
	this.client.log(content);

};

module.exports.Bunyan2Loggly = Bunyan2Loggly;<commit_msg>Log only the first element of content in order to preserve tags (https://github.com/smebberson/bunyan-loggly/issues/3).<commit_after>
var loggly = require('loggly'),
	util = require('util');

function Bunyan2Loggly (logglyConfig, buffer) {

	this.logglyConfig = logglyConfig || {};

	// define the log as being json (because bunyan is a json logger)
	this.logglyConfig.json = true;

	// define the buffer count, unless one has already been defined
	this.buffer = buffer || 1;
	this._buffer = [];

	// add the https tag by default, just to make the loggly source setup work as expect
	this.logglyConfig.tags = this.logglyConfig.tags || [];
	this.logglyConfig.tags.push('https');

	// create the client
	this.client = loggly.createClient(logglyConfig);

}

Bunyan2Loggly.prototype.write = function(rec) {

	if (typeof rec !== 'object' && !Array.isArray(rec)) {
		throw new Error('bunyan-loggly requires a raw stream. Please define the type as raw when setting up the bunyan stream.');
	}

	if (typeof rec === 'object') {

		// loggly prefers timestamp over time
		if (rec.time !== undefined) {
			rec.timestamp = rec.time;
			delete rec.time;
		}

	}

	// write to our array buffer
	this._buffer.push(rec);

	// check the buffer, we may or may not need to send to loggly
	this.checkBuffer();

};

Bunyan2Loggly.prototype.checkBuffer = function () {

	if (this._buffer.length < this.buffer) {
		return;
	}

	// duplicate the array, because it could be modified before our HTTP call succeeds
	var content = this._buffer.slice();
	this._buffer = [];

	// log multiple (or single) requests with loggly
	this.client.log(content[0]);

};

module.exports.Bunyan2Loggly = Bunyan2Loggly;
{'fraction_non_alphanumeric': 0.12210915818686402, 'fraction_numerical': 0.004316990440949738, 'mean_word_length': 3.7705882352941176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2024705', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1014, 'n_words': 329}