<commit_before>/*!
 * base-logger <https://github.com/node-base/base-logger>
 *
 * Copyright (c) 2016, <NAME>.
 * Licensed under the MIT License.
 */

'use strict';

var utils = require('./utils');

/**
 * Add [verbalize][] instance to app as `.logger`.
 * Adds logger and mode methods to the `app` directly for easy logging.
 * Sets up a default listener to handle log events and write messages to
 * `process.stdout`
 *
 * Pass `options.defaultListener = false` to disable the default listener.
 *
 * ```js
 * var options {
 *   defaultListener: true
 * };
 *
 * app.use(logger(options));
 * app.verbose.info('info message');
 * ```
 * @param  {Objects} `options` Options used when creating the logger.
 * @return {Function} plugin function to pass to `app.use`
 * @api public
 */

module.exports = function logger(options) {
  var opts = utils.extend({defaultListener: true}, options);
  var Logger = utils.verbalize.create();

  return function plugin(app) {
    if (typeof this['logger'] !== 'undefined') return;
    var logger = new Logger();
    logger.options = this.options;
    logger.on('addLogger', addMethod(this));
    logger.on('addMode', addMethod(this));

    addMethods(this, logger.modifiers);
    addMethods(this, logger.modes);

    if (opts.defaultListener === true) {
      logger.on('*', function(name, stats) {
        this.handle(stats);
      });
    }

    this.define('logger', {
      enumerable: true,
      configurable: true,
      get: function() {
        function fn() {<commit_msg>sync app options with logger options<commit_after>/*!
 * base-logger <https://github.com/node-base/base-logger>
 *
 * Copyright (c) 2016, <NAME>.
 * Licensed under the MIT License.
 */

'use strict';

var utils = require('./utils');

/**
 * Add [verbalize][] instance to app as `.logger`.
 * Adds logger and mode methods to the `app` directly for easy logging.
 * Sets up a default listener to handle log events and write messages to
 * `process.stdout`
 *
 * Pass `options.defaultListener = false` to disable the default listener.
 *
 * ```js
 * var options {
 *   defaultListener: true
 * };
 *
 * app.use(logger(options));
 * app.verbose.info('info message');
 * ```
 * @param  {Objects} `options` Options used when creating the logger.
 * @return {Function} plugin function to pass to `app.use`
 * @api public
 */

module.exports = function logger(options) {
  var opts = utils.extend({defaultListener: true}, options);
  var Logger = utils.verbalize.create();

  return function plugin(app) {
    if (typeof this['logger'] !== 'undefined') return;
    var self = this;
    var logger = new Logger();
    utils.sync(logger, 'options', function() {
      return self.options;
    });

    logger.on('addLogger', addMethod(this));
    logger.on('addMode', addMethod(this));

    addMethods(this, logger.modifiers);
    addMethods(this, logger.modes);

    if (opts.defaultListener === true) {
      logger.on('*', function(name, stats) {
        this.handle(stats);
      });
    }

    this.define('logger', {
      enumerable: true,
      configurable: true,
      get: function() {
        function fn() {
{'fraction_non_alphanumeric': 0.15217391304347827, 'fraction_numerical': 0.0025575447570332483, 'mean_word_length': 3.327800829875519, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3556288', 'n_tokens_mistral': 938, 'n_tokens_neox': 928, 'n_words': 279}