<commit_before>/**
 * Copyright: (c) 2016 <NAME>
 * License: MIT
 */

var Logger = (function (window, document) {
	"use strict";

	var console = window.console;
	var concat = Array.prototype.concat;

	function Logger(name) {
		this.name = name;
	}

	Logger.prototype._call = function (thisArg, fn, args) {
		var prefix = this.name ? ["[" + this.name + "]"] : [];
		var allArgs = concat.apply(prefix, args);
		fn.apply(thisArg, allArgs);
	};

	Logger.prototype.debug = function () {
		this._call(console, console.log, arguments);
	};

	Logger.prototype.info = function () {
		this._call(console, console.info, arguments);
	};

	Logger.prototype.warn = function () {
		this._call(console, console.warn, arguments);
	};

	Logger.prototype.error = function () {
		this._call(console, console.error, arguments);
	};

	return Logger;
})(window, document);<commit_msg>Support for disabling and setting visible logging levels<commit_after>/**
 * Copyright: (c) 2016 <NAME>
 * License: MIT
 */

var Logger = (function (window, document) {
	"use strict";

	var console = window.console;
	var concat = Array.prototype.concat;

	var enabledGlobally = true,
		globalLevel = 0;

	var levelIndices = {
		"debug": 0,
		"info": 1,
		"warn": 2,
		"error": 3
	};

	function Logger(name, enabled, level) {
		this.name = name;
		this.enabled = enabled !== false;
		this.level = levelIndices.hasOwnProperty(level) ? levelIndices[level] : 0;
	}

	Logger.prototype._call = function (thisArg, fn, args) {
		var prefix = this.name ? ["[" + this.name + "]"] : [];
		var allArgs = concat.apply(prefix, args);
		fn.apply(thisArg, allArgs);
	};

	Logger.prototype.enable = function () {
		this.enabled = true;
	};

	Logger.prototype.disable = function () {
		this.enabled = false;
	};

	Logger.prototype.setLevel = function (level) {
		if(levelIndices.hasOwnProperty(level)) {
			this.level = levelIndices[level];
		}
	};

	Logger.prototype.debug = function () {
		if(enabledGlobally && this.enabled &&
			globalLevel <= 0 && this.level <= 0) {
			this._call(console, console.log, arguments);
		}
	};

	Logger.prototype.info = function () {
		if(enabledGlobally && this.enabled &&
			globalLevel <= 1 && this.level <= 1) {
			this._call(console, console.info, arguments);
		}
	};

	Logger.prototype.warn = function () {
		if(enabledGlobally && this.enabled &&
			globalLevel <= 2 && this.level <= 2) {
			this._call(console, console.warn, arguments);
		}
	};

	Logger.prototype.error = function () {
		if(enabledGlobally && this.enabled &&
			globalLevel <= 3 && this.level <= 3) {
			this._call(console, console.error, arguments);
		}
	};

	Logger.enable = function () {
		enabledGlobally = true;
	};

	Logger.disable = function () {
		enabledGlobally = false;
	};

	Logger.setLevel = function (level) {
		if(levelIndices.hasOwnProperty(level)) {
			globalLevel = levelIndices[level];
		}
	};

	return Logger;
})(window, document);
{'fraction_non_alphanumeric': 0.16299104066161269, 'fraction_numerical': 0.007580978635423846, 'mean_word_length': 3.728013029315961, 'pattern_counts': {'":': 4, '<': 13, '<?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': '6493374', 'n_tokens_mistral': 1050, 'n_tokens_neox': 955, 'n_words': 208}