Comparing version
{ | ||
"name": "js-logger", | ||
"version": "0.9.13", | ||
"version": "0.9.14", | ||
"main": "src/logger.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -0,1 +1,4 @@ | ||
## 0.9.14 (4th September, 2014) | ||
- Fix for IE7 (#10, @james-west) | ||
## 0.9.12 (13th July, 2014) | ||
@@ -2,0 +5,0 @@ - Fixed `release` task to correctly push tags to origin. |
{ | ||
"name": "js-logger", | ||
"version": "0.9.13", | ||
"version": "0.9.14", | ||
"description": "Lightweight, unobtrusive, configurable JavaScript logger", | ||
@@ -5,0 +5,0 @@ "author": "Jonny Reeves (http://jonnyreeves.co.uk)", |
@@ -16,3 +16,3 @@ /*! | ||
// For those that are at home that are keeping score. | ||
Logger.VERSION = "0.9.13"; | ||
Logger.VERSION = "0.9.14"; | ||
@@ -154,3 +154,3 @@ // Function which handles all incoming log messages. | ||
// Check for the presence of a logger. | ||
if (!console) { | ||
if (typeof console === "undefined") { | ||
return; | ||
@@ -157,0 +157,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e){"use strict";var n={};n.VERSION="0.9.13";var o,t={},r=function(e,n){return function(){return n.apply(e,arguments)}},i=function(){var e,n,o=arguments,t=o[0];for(n=1;n<o.length;n++)for(e in o[n])e in t||!o[n].hasOwnProperty(e)||(t[e]=o[n][e]);return t},l=function(e,n){return{value:e,name:n}};n.DEBUG=l(1,"DEBUG"),n.INFO=l(2,"INFO"),n.WARN=l(4,"WARN"),n.ERROR=l(8,"ERROR"),n.OFF=l(99,"OFF");var u=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};u.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},enabledFor:function(e){var n=this.context.filterLevel;return e.value>=n.value},debug:function(){this.invoke(n.DEBUG,arguments)},info:function(){this.invoke(n.INFO,arguments)},warn:function(){this.invoke(n.WARN,arguments)},error:function(){this.invoke(n.ERROR,arguments)},invoke:function(e,n){o&&this.enabledFor(e)&&o(n,i({level:e},this.context))}};var s=new u({filterLevel:n.OFF});!function(){var e=n;e.enabledFor=r(s,s.enabledFor),e.debug=r(s,s.debug),e.info=r(s,s.info),e.warn=r(s,s.warn),e.error=r(s,s.error),e.log=e.info}(),n.setHandler=function(e){o=e},n.setLevel=function(e){s.setLevel(e);for(var n in t)t.hasOwnProperty(n)&&t[n].setLevel(e)},n.get=function(e){return t[e]||(t[e]=new u(i({name:e},s.context)))},n.useDefaults=function(e){console&&(n.setLevel(e||n.DEBUG),n.setHandler(function(e,o){var t=console.log;o.name&&(e[0]="["+o.name+"] "+e[0]),o.level===n.WARN&&console.warn?t=console.warn:o.level===n.ERROR&&console.error?t=console.error:o.level===n.INFO&&console.info&&(t=console.info),Function.prototype.apply.call(t,console,e)}))},"function"==typeof define&&define.amd?define(n):"undefined"!=typeof module&&module.exports?module.exports=n:(n._prevLogger=e.Logger,n.noConflict=function(){return e.Logger=n._prevLogger,n},e.Logger=n)}(this); | ||
!function(e){"use strict";var n={};n.VERSION="0.9.13";var o,t={},r=function(e,n){return function(){return n.apply(e,arguments)}},i=function(){var e,n,o=arguments,t=o[0];for(n=1;n<o.length;n++)for(e in o[n])e in t||!o[n].hasOwnProperty(e)||(t[e]=o[n][e]);return t},l=function(e,n){return{value:e,name:n}};n.DEBUG=l(1,"DEBUG"),n.INFO=l(2,"INFO"),n.WARN=l(4,"WARN"),n.ERROR=l(8,"ERROR"),n.OFF=l(99,"OFF");var u=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};u.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},enabledFor:function(e){var n=this.context.filterLevel;return e.value>=n.value},debug:function(){this.invoke(n.DEBUG,arguments)},info:function(){this.invoke(n.INFO,arguments)},warn:function(){this.invoke(n.WARN,arguments)},error:function(){this.invoke(n.ERROR,arguments)},invoke:function(e,n){o&&this.enabledFor(e)&&o(n,i({level:e},this.context))}};var f=new u({filterLevel:n.OFF});!function(){var e=n;e.enabledFor=r(f,f.enabledFor),e.debug=r(f,f.debug),e.info=r(f,f.info),e.warn=r(f,f.warn),e.error=r(f,f.error),e.log=e.info}(),n.setHandler=function(e){o=e},n.setLevel=function(e){f.setLevel(e);for(var n in t)t.hasOwnProperty(n)&&t[n].setLevel(e)},n.get=function(e){return t[e]||(t[e]=new u(i({name:e},f.context)))},n.useDefaults=function(e){"undefined"!=typeof console&&(n.setLevel(e||n.DEBUG),n.setHandler(function(e,o){var t=console.log;o.name&&(e[0]="["+o.name+"] "+e[0]),o.level===n.WARN&&console.warn?t=console.warn:o.level===n.ERROR&&console.error?t=console.error:o.level===n.INFO&&console.info&&(t=console.info),Function.prototype.apply.call(t,console,e)}))},"function"==typeof define&&define.amd?define(n):"undefined"!=typeof module&&module.exports?module.exports=n:(n._prevLogger=e.Logger,n.noConflict=function(){return e.Logger=n._prevLogger,n},e.Logger=n)}(this); |
@@ -135,2 +135,25 @@ module("Logger", { | ||
ok(this.calls.length === 1, "Logger.setLevel() sets log filter level for all named loggers"); | ||
}); | ||
}); | ||
test("Logger.useDefaults logs to console", function () { | ||
var logger = this.logger; | ||
var sandbox = sinon.sandbox.create(); | ||
sandbox.stub(console, "log"); | ||
sandbox.stub(console, "info"); | ||
sandbox.stub(console, "warn"); | ||
sandbox.stub(console, "error"); | ||
logger.useDefaults(); | ||
logger.debug("debug message"); | ||
logger.info("info message"); | ||
logger.warn("warning message"); | ||
logger.error("error message"); | ||
ok(console.log.calledOnce, "logger.debug calls console.log"); | ||
ok(console.info.calledOnce, "logger.info calls console.info"); | ||
ok(console.warn.calledOnce, "logger.warn calls console.warn"); | ||
ok(console.error.calledOnce, "logger.error calls console.error"); | ||
sandbox.restore(); | ||
}); |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
241826
193.47%13
8.33%6524
180.48%3
200%