<commit_before>/*
 * logger.js: Core logger object used by winston.
 *
 * (C) 2010 <NAME>
 * MIT LICENCE
 *
 */
 
var events = require('events'),
    util = require('util'),
    async = require('async'),
    config = require('./config'),
    common = require('./common'),
    exception = require('./exception');

function capitalize(str) {
  return str && str[0].toUpperCase() + str.slice(1);
}

//
// Time constants
//
var ticksPerMillisecond = 10000;

//
// ### function Logger (options)
// #### @options {Object} Options for this instance.
// Constructor function for the Logger object responsible
// for persisting log messages and metadata to one or more transports.
//
var Logger = exports.Logger = function (options) {
  events.EventEmitter.call(this);
  options = options || {};
  
  var self = this;
  
  //
  // Set Levels and default logging level
  //
  this.padLevels = options.padLevels || false;
  this.setLevels(options.levels);
  
  //
  // Setup other intelligent default settings.
  //
  this.level             = options.level || 'info';
  this.emitErrs          = options.emitErrs || false;
  this.stripColors       = options.stripColors || false;
  this.transports        = {};
  this.exceptionHandlers = {};
  this.profilers         = {};
  this._names            = [];
  this._hnames           = [];
  
  if (options.transports) {
    options.transports.forEach(function (transport) {
      self.add(transport, null, true);
    });
  }
  
  if (options.exceptionHandlers) {
    options.exceptionHandlers.forEach(function (handler) {
      self._hnames.push(handler.name);
      self.exceptionHandlers[handler.name] = handler;
    });
  }
  
  if (options.handleExceptions) {
    this.handleExceptions();
  }
};

//
// Inherit from `events.EventEmitter`.
//
util.inherits(Logger, events.EventEmitter);

//
// ### function extend (target)
// #### @target {Object} Target to extend.
// Extends the target object with a 'log' method
// along with a method for each level in this instance.
//
Logger.prototype.extend = function (target) {
  var self = this;
  ['log', 'profile'].concat(Object.keys(this.levels)).forEach(function (method) {
    target[method] = function () {
      return self[method].apply(self, arguments);
    };
  });
  
  return this;
};<commit_msg>[api] Call `.handleExceptions()` if any transports have `.handleExceptions` set to true<commit_after>/*
 * logger.js: Core logger object used by winston.
 *
 * (C) 2010 <NAME>
 * MIT LICENCE
 *
 */
 
var events = require('events'),
    util = require('util'),
    async = require('async'),
    config = require('./config'),
    common = require('./common'),
    exception = require('./exception');

function capitalize(str) {
  return str && str[0].toUpperCase() + str.slice(1);
}

//
// Time constants
//
var ticksPerMillisecond = 10000;

//
// ### function Logger (options)
// #### @options {Object} Options for this instance.
// Constructor function for the Logger object responsible
// for persisting log messages and metadata to one or more transports.
//
var Logger = exports.Logger = function (options) {
  events.EventEmitter.call(this);
  options = options || {};
  
  var self = this,
      handleExceptions = false;
  
  //
  // Set Levels and default logging level
  //
  this.padLevels = options.padLevels || false;
  this.setLevels(options.levels);
  
  //
  // Setup other intelligent default settings.
  //
  this.level             = options.level || 'info';
  this.emitErrs          = options.emitErrs || false;
  this.stripColors       = options.stripColors || false;
  this.transports        = {};
  this.exceptionHandlers = {};
  this.profilers         = {};
  this._names            = [];
  this._hnames           = [];
  
  if (options.transports) {
    options.transports.forEach(function (transport) {
      self.add(transport, null, true);
      
      if (transport.handleExceptions) {
        handleExceptions = true;
      }
    });
  }
  
  if (options.exceptionHandlers) {
    options.exceptionHandlers.forEach(function (handler) {
      self._hnames.push(handler.name);
      self.exceptionHandlers[handler.name] = handler;
    });
  }
  
  if (options.handleExceptions || handleExceptions) {
    this.handleExceptions();
  }
};

//
// Inherit from `events.EventEmitter`.
//
util.inherits(Logger, events.EventEmitter);

//
// ### function extend (target)
// #### @target {Object} Target to extend.
// Extends the target object with a 'log' method
// along with a method for each level in this instance.
//
Logger.prototype.extend = function (target) {
  var self = this;
  ['log', 'profile'].concat(Object.keys(this.levels)).forEach(function (method) {
    target[method] = function () {
      return self[method].apply(self, arguments);
    };
  });
  
  return this;
};
{'fraction_non_alphanumeric': 0.14968684759916492, 'fraction_numerical': 0.004592901878914405, 'mean_word_length': 2.8297362110311752, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3355030', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1440, 'n_words': 353}