custom-log
Advanced tools
Comparing version 0.1.6 to 0.1.7
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
"use strict"; | ||
var customLog, | ||
var customLog, intoArray, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
intoArray = function(string) { | ||
return string.split(' '); | ||
}; | ||
customLog = function(init) { | ||
@@ -77,2 +81,34 @@ var CUSTOM_LOG, Log, fn, level, log, logInstance, message, prefixMsg; | ||
log = logInstance.log; | ||
log.disable = function(names) { | ||
var i, len, name, results; | ||
names = intoArray(names); | ||
results = []; | ||
for (i = 0, len = names.length; i < len; i++) { | ||
name = names[i]; | ||
if (name === 'log') { | ||
results.push(logInstance.disable()); | ||
} else if (log[name] != null) { | ||
results.push(log[name].disable()); | ||
} else { | ||
results.push(void 0); | ||
} | ||
} | ||
return results; | ||
}; | ||
log.enable = function(names) { | ||
var i, len, name, results; | ||
names = intoArray(names); | ||
results = []; | ||
for (i = 0, len = names.length; i < len; i++) { | ||
name = names[i]; | ||
if (name === 'log') { | ||
results.push(logInstance.enable()); | ||
} else if (log[name] != null) { | ||
results.push(log[name].enable()); | ||
} else { | ||
results.push(void 0); | ||
} | ||
} | ||
return results; | ||
}; | ||
if (typeof init === 'object') { | ||
@@ -79,0 +115,0 @@ fn = function(level, message) { |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var customLog,bind=function(e,t){return function(){return e.apply(t,arguments)}};customLog=function(init){var CUSTOM_LOG,Log,fn,level,log,logInstance,message,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){var n,i;this.level=null!=e?e:"log",this.message=null!=t?t:"",this.assert=bind(this.assert,this),this.enable=bind(this.enable,this),this.disable=bind(this.disable,this),this.enabled=!0,this.log=function(e){return function(){var t;return e.enabled?log.apply(console,(t=[e.message]).concat.apply(t,arguments)):void 0}}(this);for(n in this)i=this[n],this.hasOwnProperty(n)&&"log"!==n&&(this.log[n]=i)}var log;return log=console.log,Log.prototype.disable=function(){return this.enabled=!1,log(CUSTOM_LOG+"."+this.level+" has been disabled")},Log.prototype.enable=function(){return this.enabled=!0,log(CUSTOM_LOG+"."+this.level+" is now enabled")},Log.prototype.assert=function(predicate,description){return null==description&&(description=""),description?description='"'+description+'"':"string"==typeof predicate&&(description=predicate),"string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n "+customLog.assertMessage+"("+description+") == "+predicate+"\n")},Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,"object"==typeof init){fn=function(e,t){switch(e){case"log":return logInstance.message=t;case"assert":return customLog.assertMessage=t;default:return log[e]=new Log(e,t).log}};for(level in init)message=init[level],fn(level,message)}return log},customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return customLog}):"undefined"!=typeof module?module.exports=customLog:"undefined"!=typeof window&&(window.customLog=customLog)}).call(this); | ||
(function(){"use strict";var customLog,intoArray,bind=function(e,t){return function(){return e.apply(t,arguments)}};intoArray=function(e){return e.split(" ")},customLog=function(init){var CUSTOM_LOG,Log,fn,level,log,logInstance,message,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){var n,o;this.level=null!=e?e:"log",this.message=null!=t?t:"",this.assert=bind(this.assert,this),this.enable=bind(this.enable,this),this.disable=bind(this.disable,this),this.enabled=!0,this.log=function(e){return function(){var t;return e.enabled?log.apply(console,(t=[e.message]).concat.apply(t,arguments)):void 0}}(this);for(n in this)o=this[n],this.hasOwnProperty(n)&&"log"!==n&&(this.log[n]=o)}var log;return log=console.log,Log.prototype.disable=function(){return this.enabled=!1,log(CUSTOM_LOG+"."+this.level+" has been disabled")},Log.prototype.enable=function(){return this.enabled=!0,log(CUSTOM_LOG+"."+this.level+" is now enabled")},Log.prototype.assert=function(predicate,description){return null==description&&(description=""),description?description='"'+description+'"':"string"==typeof predicate&&(description=predicate),"string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n "+customLog.assertMessage+"("+description+") == "+predicate+"\n")},Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,log.disable=function(e){var t,n,o,i;for(e=intoArray(e),i=[],t=0,n=e.length;n>t;t++)o=e[t],i.push("log"===o?logInstance.disable():null!=log[o]?log[o].disable():void 0);return i},log.enable=function(e){var t,n,o,i;for(e=intoArray(e),i=[],t=0,n=e.length;n>t;t++)o=e[t],i.push("log"===o?logInstance.enable():null!=log[o]?log[o].enable():void 0);return i},"object"==typeof init){fn=function(e,t){switch(e){case"log":return logInstance.message=t;case"assert":return customLog.assertMessage=t;default:return log[e]=new Log(e,t).log}};for(level in init)message=init[level],fn(level,message)}return log},customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return customLog}):"undefined"!=typeof module?module.exports=customLog:"undefined"!=typeof window&&(window.customLog=customLog)}).call(this); |
{ | ||
"name": "custom-log", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "A tiny flexible logger", | ||
@@ -5,0 +5,0 @@ "main": "custom-log.min.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132
46858
6