<commit_before>/*
 * index.js: Top level module include for log module.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var winston = require('winston'),
    haibu = require('haibu');

//
// Define the set of loggers and inputs used by this module
//
var logger     = exports,
    loggers    = {},
    listening  = {}
    inputs     = ['haibu', 'drone'];
  
//
// Setup mapping of special namespaces to inputs 
//  
var namespaces = {
  'drone': 'drone'
};

var defaultConfig = {
  console: {
    level: 'silly',
    colorize: false
  }
};

//
// Define a value indicating if this module is initialized
//
logger.initialized = false;

//
// ### function init (options, callback) 
// #### @options {Object} Options to initialize this plugin with
// #### @callback {function} Continuation to respond to when complete
// Initalizes the `logger` plugin in the current `haibu` environment. 
//
logger.init = function (options) {
  if (logger.initialized) {
    return;
  }
  
  //
  // Monkey punch `haibu.emit` to allow for lazy listening
  // of logging events.
  //
  var _emit = haibu.emit;
  haibu.emit = function (ev) {
    if (ev !== 'newListener') {
      if (!listening[ev]) {
        listening[ev] = true;
        haibu.on(ev, function () {
          var args = Array.prototype.slice.call(arguments);
          args.unshift(ev);
          logEvent.apply(null, args);
        });
      }

      _emit.apply(haibu, arguments);
    }
  };
  
  // Initialize a new winston logger for each input
  inputs.forEach(function (input) {
    initInput(input, options);
  });
  
  logger.initialized = true;
};

//
// function initInput (input, options)
// Helper function for initializing individual
// inputs used by the logging module's methods
// e.g. drone, app, etc
//
function initInput (input, options) {
  var transports = [];

  //
  // Create the transports for this input. Here we are 
  // defaulting to Console and Loggly.
  //
  transports.push(new winston.transports.Console(options.console || defaultConfig.console));
  
  // Only add the Loggly transport if the input token is 
  // in the options passed to 'init' 
  if (options.loggly && options.loggly.inputs[input]) {
    transports.push(new winston.transports.Loggly({<commit_msg>[minor] Expose additional methods on the logger plugin<commit_after>/*
 * index.js: Top level module include for log module.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var winston = require('winston'),
    haibu = require('haibu');

//
// Define the set of loggers and inputs used by this module
//
var logger     = exports,
    loggers    = exports.loggers   = {},
    listening  = exports.listening = {}
    inputs     = exports.inputs    = ['haibu', 'drone'];
  
//
// Setup mapping of special namespaces to inputs 
//  
var namespaces = exports.namespaces = {
  'drone': 'drone'
};

var defaultConfig = {
  console: {
    level: 'silly',
    colorize: false
  }
};

//
// Define a value indicating if this module is initialized
//
logger.initialized = false;

//
// ### function init (options, callback) 
// #### @options {Object} Options to initialize this plugin with
// #### @callback {function} Continuation to respond to when complete
// Initalizes the `logger` plugin in the current `haibu` environment. 
//
logger.init = function (options) {
  if (logger.initialized) {
    return;
  }
  
  //
  // Monkey punch `haibu.emit` to allow for lazy listening
  // of logging events.
  //
  var _emit = haibu.emit;
  haibu.emit = function (ev) {
    if (ev !== 'newListener') {
      if (!listening[ev]) {
        listening[ev] = true;
        haibu.on(ev, function () {
          var args = Array.prototype.slice.call(arguments);
          args.unshift(ev);
          logEvent.apply(null, args);
        });
      }

      _emit.apply(haibu, arguments);
    }
  };
  
  // Initialize a new winston logger for each input
  inputs.forEach(function (input) {
    logger.initInput(input, options);
  });
  
  logger.initialized = true;
};

//
// function initInput (input, options)
// Helper function for initializing individual
// inputs used by the logging module's methods
// e.g. drone, app, etc
//
logger.initInput = function (input, options) {
  var transports = [];

  //
  // Create the transports for this input. Here we are 
  // defaulting to Console and Loggly.
  //
  transports.push(new winston.transports.Console(options.console || defaultConfig.console));
  
  // Only add the Loggly transport if the input token is 
  // in the options passed to 'init' 
  if (options.loggly && options.loggly.inputs[input]) {
    transports.push(new winston.transports.Loggly({
{'fraction_non_alphanumeric': 0.13334778837814398, 'fraction_numerical': 0.0017346053772766695, 'mean_word_length': 2.6845047923322682, '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': '2945178', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1429, 'n_words': 436}