<commit_before>// Copyright 2014, Renasar Technologies Inc.
/* jshint: node:true */

'use strict';

var di = require('di');

module.exports = loggingProtocolFactory;

di.annotate(loggingProtocolFactory, new di.Provide('Protocol.Logging'));
di.annotate(loggingProtocolFactory,
    new di.Inject(
        'Assert',
        'Constants',
        'Services.Messenger',
        '_',
        'Result'
    )
);

function loggingProtocolFactory (assert, Constants, messenger, _, Result) {
    var levels = _.keys(Constants.Logging.Levels);

    function LoggingProtocol() {
    }

    /**
     * Sends a log message out over the messenger...
     *
     * @param level {string} one of ['emerg','alert','crit','error','warning',
     *                       'notice','info','debug','silly']
     * @param data {Object}
     * @returns {Q.promise} resolving if everything worked, rejecting with
     *                      relevant error if it didn't
     */
    LoggingProtocol.prototype.publishLog = function (level, data) {
        assert.isIn(level, levels);
        assert.object(data, 'data');

        return messenger.publish(
            Constants.Protocol.Exchanges.Logging.Name,
            level,
            new Result({ value: data })
        );
    };

    /**
     * Subscribes to the log feed for the given message level
     *
     * @param level {string} one of ['emerg','alert','crit','error','warning',<commit_msg>fixing missing Q<commit_after>// Copyright 2014, Renasar Technologies Inc.
/* jshint: node:true */

'use strict';

var di = require('di');

module.exports = loggingProtocolFactory;

di.annotate(loggingProtocolFactory, new di.Provide('Protocol.Logging'));
di.annotate(loggingProtocolFactory,
    new di.Inject(
        'Assert',
        'Constants',
        'Services.Messenger',
        '_',
        'Result',
        'Q'
    )
);

function loggingProtocolFactory (assert, Constants, messenger, _, Result, Q) {
    var levels = _.keys(Constants.Logging.Levels);

    function LoggingProtocol() {
    }

    /**
     * Sends a log message out over the messenger...
     *
     * @param level {string} one of ['emerg','alert','crit','error','warning',
     *                       'notice','info','debug','silly']
     * @param data {Object}
     * @returns {Q.promise} resolving if everything worked, rejecting with
     *                      relevant error if it didn't
     */
    LoggingProtocol.prototype.publishLog = function (level, data) {
        assert.isIn(level, levels);
        assert.object(data, 'data');

        return messenger.publish(
            Constants.Protocol.Exchanges.Logging.Name,
            level,
            new Result({ value: data })
        );
    };

    /**
     * Subscribes to the log feed for the given message level
     *
     * @param level {string} one of ['emerg','alert','crit','error','warning',
{'fraction_non_alphanumeric': 0.13603069410533658, 'fraction_numerical': 0.0027903732124171608, 'mean_word_length': 2.4429771908763507, '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': '3590114', 'n_tokens_mistral': 829, 'n_tokens_neox': 786, 'n_words': 201}