<commit_before>'use strict';

var assert = require('assert');
var collectParallel = require('collect-parallel/array');

var LogMessage = require('./log-message.js');
var LEVELS = require('./levels.js').LEVELS_BY_NAME;

module.exports = BaseLogtron;

function BaseLogtron(opts) {
    /* istanbul ignore next */
    if (!(this instanceof BaseLogtron)) {
        return new BaseLogtron(opts);
    }

    assert(Array.isArray(opts.streams),
        'opts.streams must be an array');

    this._streams = opts.streams;
}

BaseLogtron.prototype._log = function _log(level, msg, meta, cb) {
    var logMessage = new LogMessage(level, msg, meta);
    LogMessage.isValid(logMessage);

    collectParallel(this._streams, writeMessage, cb || noop);

    function writeMessage(stream, i, callback) {
        stream.write(logMessage, callback);
    }
};

BaseLogtron.prototype.trace = function trace(msg, meta, cb) {
    this._log(LEVELS.trace, msg, meta, cb);
};

BaseLogtron.prototype.debug = function debug(msg, meta, cb) {
    this._log(LEVELS.debug, msg, meta, cb);
};

BaseLogtron.prototype.info = function info(msg, meta, cb) {
    this._log(LEVELS.info, msg, meta, cb);
};

BaseLogtron.prototype.access = function access(msg, meta, cb) {
    this._log(LEVELS.access, msg, meta, cb);
};

BaseLogtron.prototype.warn = function warn(msg, meta, cb) {
    this._log(LEVELS.warn, msg, meta, cb);
};

BaseLogtron.prototype.error = function error(msg, meta, cb) {
    this._log(LEVELS.error, msg, meta, cb);
};

BaseLogtron.prototype.fatal = function fatal(msg, meta, cb) {
    this._log(LEVELS.fatal, msg, meta, cb);
};

function noop() {}
<commit_msg>add writeEntry method for Logtron compat interface<commit_after>'use strict';

var assert = require('assert');
var collectParallel = require('collect-parallel/array');

var LogMessage = require('./log-message.js');
var LEVELS = require('./levels.js').LEVELS_BY_NAME;

module.exports = BaseLogtron;

function BaseLogtron(opts) {
    /* istanbul ignore next */
    if (!(this instanceof BaseLogtron)) {
        return new BaseLogtron(opts);
    }

    assert(Array.isArray(opts.streams),
        'opts.streams must be an array');

    this._streams = opts.streams;
}

BaseLogtron.prototype._log = function _log(level, msg, meta, cb) {
    var logMessage = new LogMessage(level, msg, meta);
    LogMessage.isValid(logMessage);

    collectParallel(this._streams, writeMessage, cb || noop);

    function writeMessage(stream, i, callback) {
        stream.write(logMessage, callback);
    }
};

// Logtron compatible writeEntry, assumes `entry` is a `logtron/entry`
BaseLogtron.prototype.writeEntry = function writeEntry(entry, cb) {
    var logMessage = new LogMessage(
        LEVELS[entry.level], 
        entry.message, 
        entry.meta, 
        entry.path
    );

    LogMessage.isValid(logMessage);

    collectParallel(this._streams, writeMessage, cb || noop);

    function writeMessage(stream, i, callback) {
        stream.write(logMessage, callback);
    }
};

BaseLogtron.prototype.trace = function trace(msg, meta, cb) {
    this._log(LEVELS.trace, msg, meta, cb);
};

BaseLogtron.prototype.debug = function debug(msg, meta, cb) {
    this._log(LEVELS.debug, msg, meta, cb);
};

BaseLogtron.prototype.info = function info(msg, meta, cb) {
    this._log(LEVELS.info, msg, meta, cb);
};

BaseLogtron.prototype.access = function access(msg, meta, cb) {
    this._log(LEVELS.access, msg, meta, cb);
};

BaseLogtron.prototype.warn = function warn(msg, meta, cb) {
    this._log(LEVELS.warn, msg, meta, cb);
};

BaseLogtron.prototype.error = function error(msg, meta, cb) {
    this._log(LEVELS.error, msg, meta, cb);
};

BaseLogtron.prototype.fatal = function fatal(msg, meta, cb) {
    this._log(LEVELS.fatal, msg, meta, cb);
};

function noop() {}

{'fraction_non_alphanumeric': 0.14349657714586625, 'fraction_numerical': 0.0, 'mean_word_length': 3.8705128205128205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6094951', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1226, 'n_words': 285}