<commit_before>'use strict';

var LEVELS = require('./Levels')
  , Logger = require('./Logger')
  , Uploader = require('./Uploader');


// Map of loggers created. Same name loggers exist only once.
var loggers = {};

function LoggerFactory () {
  this.LEVELS = LEVELS;
}

module.exports = new LoggerFactory();

/**
 * Get a named logger instance.
 * @param {String}    [name]
 * @param {Number}    [level]
 * @param {Boolean}   [upload]
 */
LoggerFactory.prototype.getLogger = function (name, level, upload) {
  name = name || '';

  if (upload) {
    Uploader.startInterval();
  }

  if (loggers[name]) {
    return loggers[name];
  } else {
    loggers[name] = new Logger(name, level, upload);

    return loggers[name];
  }
};


/**
 * Set the function that will be used for log uplaod
 * @param {Function}
 */
LoggerFactory.prototype.setUploadFn = Uploader.setUploadFn;


/**
 * Invoke an upload of logs.<commit_msg>Docs and support silent mode<commit_after>'use strict';

var Logger = require('./Logger')
  , Uploader = require('./Uploader')
  , LEVELS = require('./Levels');


// Map of loggers created. Same name loggers exist only once.
var loggers = {};

/**
 * @constructor
 * @private
 * Used to create instances
 */
function LoggerFactory () {
  this.LEVELS = LEVELS;
}

module.exports = new LoggerFactory();

/**
 * @public
 * Get a named logger instance creating it if it doesn't already exist.
 * @param   {String}    [name]
 * @param   {Number}    [level]
 * @param   {Boolean}   [upload]
 * @param   {Boolean}   [silent]
 * @returns {Logger}
 */
LoggerFactory.prototype.getLogger = function (name, level, upload, silent) {
  name = name || '';

  if (upload) {
    Uploader.startInterval();
  }

  if (loggers[name]) {
    return loggers[name];
  } else {
    loggers[name] = new Logger(name, level, upload, silent);

    return loggers[name];
  }
};


/**
 * @public
 * Set the function that will be used to upload logs.
 * @param {Function} uploadFn
 */
LoggerFactory.prototype.setUploadFn = Uploader.setUploadFn;


/**
 * @public
 * Force logs to upload at this time.
{'fraction_non_alphanumeric': 0.14949688548155246, 'fraction_numerical': 0.0, 'mean_word_length': 3.3229813664596275, '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': '7618627', 'n_tokens_mistral': 684, 'n_tokens_neox': 665, 'n_words': 195}