Socket
Socket
Sign inDemoInstall

loglevel

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.5.0

2

bower.json
{
"name": "loglevel",
"version": "1.4.1",
"version": "1.5.0",
"main": "dist/loglevel.min.js",

@@ -5,0 +5,0 @@ "dependencies": {},

@@ -1,2 +0,2 @@

/*! loglevel - v1.4.1 - https://github.com/pimterry/loglevel - (c) 2016 Tim Perry - licensed MIT */
/*! loglevel - v1.5.0 - https://github.com/pimterry/loglevel - (c) 2017 Tim Perry - licensed MIT */
(function (root, definition) {

@@ -13,17 +13,16 @@ "use strict";

"use strict";
// Slightly dubious tricks to cut down minimized file size
var noop = function() {};
var undefinedType = "undefined";
function realMethod(methodName) {
if (typeof console === undefinedType) {
return false; // We can't build a real method without a console to log to
} else if (console[methodName] !== undefined) {
return bindMethod(console, methodName);
} else if (console.log !== undefined) {
return bindMethod(console, 'log');
} else {
return noop;
}
}
var logMethods = [
"trace",
"debug",
"info",
"warn",
"error"
];
// Cross-browser bind equivalent that works at least back to IE6
function bindMethod(obj, methodName) {

@@ -45,13 +44,22 @@ var method = obj[methodName];

// these private functions always need `this` to be set properly
// Build the best logging method possible for this env
// Wherever possible we want to bind, not wrap, to preserve stack traces
function realMethod(methodName) {
if (methodName === 'debug') {
methodName = 'log';
}
function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
return function () {
if (typeof console !== undefinedType) {
replaceLoggingMethods.call(this, level, loggerName);
this[methodName].apply(this, arguments);
}
};
if (typeof console === undefinedType) {
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
} else if (console[methodName] !== undefined) {
return bindMethod(console, methodName);
} else if (console.log !== undefined) {
return bindMethod(console, 'log');
} else {
return noop;
}
}
// These private functions always need `this` to be set properly
function replaceLoggingMethods(level, loggerName) {

@@ -65,4 +73,20 @@ /*jshint validthis:true */

}
// Define log.log as an alias for log.debug
this.log = this.debug;
}
// In old IE versions, the console isn't present until you first open it.
// We build realMethod() replacements here that regenerate logging methods
function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
return function () {
if (typeof console !== undefinedType) {
replaceLoggingMethods.call(this, level, loggerName);
this[methodName].apply(this, arguments);
}
};
}
// By default, we use closely bound real methods wherever possible, and
// otherwise we wait for a console to appear, and then try again.
function defaultMethodFactory(methodName, level, loggerName) {

@@ -74,10 +98,2 @@ /*jshint validthis:true */

var logMethods = [
"trace",
"debug",
"info",
"warn",
"error"
];
function Logger(name, defaultLevel, factory) {

@@ -94,2 +110,4 @@ var self = this;

if (typeof window === undefinedType) return;
// Use localStorage if available

@@ -111,2 +129,4 @@ try {

if (typeof window === undefinedType) return;
try {

@@ -116,2 +136,3 @@ storedLevel = window.localStorage[storageKey];

// Fallback to cookies if local storage gives us nothing
if (typeof storedLevel === undefinedType) {

@@ -138,3 +159,3 @@ try {

*
* Public API
* Public logger API - see https://github.com/pimterry/loglevel for details
*

@@ -194,3 +215,3 @@ */

*
* Package-level API
* Top-level API
*

@@ -197,0 +218,0 @@ */

@@ -1,2 +0,2 @@

/*! loglevel - v1.4.1 - https://github.com/pimterry/loglevel - (c) 2016 Tim Perry - licensed MIT */
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";function a(a){return typeof console===h?!1:void 0!==console[a]?b(console,a):void 0!==console.log?b(console,"log"):g}function b(a,b){var c=a[b];if("function"==typeof c.bind)return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch(d){return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function c(a,b,c){return function(){typeof console!==h&&(d.call(this,b,c),this[a].apply(this,arguments))}}function d(a,b){for(var c=0;c<i.length;c++){var d=i[c];this[d]=a>c?g:this.methodFactory(d,a,b)}}function e(b,d,e){return a(b)||c.apply(this,arguments)}function f(a,b,c){function f(a){var b=(i[a]||"silent").toUpperCase();try{return void(window.localStorage[l]=b)}catch(c){}try{window.document.cookie=encodeURIComponent(l)+"="+b+";"}catch(c){}}function g(){var a;try{a=window.localStorage[l]}catch(b){}if(typeof a===h)try{var c=window.document.cookie,d=c.indexOf(encodeURIComponent(l)+"=");d&&(a=/^([^;]+)/.exec(c.slice(d))[1])}catch(b){}return void 0===k.levels[a]&&(a=void 0),a}var j,k=this,l="loglevel";a&&(l+=":"+a),k.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},k.methodFactory=c||e,k.getLevel=function(){return j},k.setLevel=function(b,c){if("string"==typeof b&&void 0!==k.levels[b.toUpperCase()]&&(b=k.levels[b.toUpperCase()]),!("number"==typeof b&&b>=0&&b<=k.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;return j=b,c!==!1&&f(b),d.call(k,b,a),typeof console===h&&b<k.levels.SILENT?"No console available for logging":void 0},k.setDefaultLevel=function(a){g()||k.setLevel(a,!1)},k.enableAll=function(a){k.setLevel(k.levels.TRACE,a)},k.disableAll=function(a){k.setLevel(k.levels.SILENT,a)};var m=g();null==m&&(m=null==b?"WARN":b),k.setLevel(m,!1)}var g=function(){},h="undefined",i=["trace","debug","info","warn","error"],j=new f,k={};j.getLogger=function(a){if("string"!=typeof a||""===a)throw new TypeError("You must supply a name when creating a logger.");var b=k[a];return b||(b=k[a]=new f(a,j.getLevel(),j.methodFactory)),b};var l=typeof window!==h?window.log:void 0;return j.noConflict=function(){return typeof window!==h&&window.log===j&&(window.log=l),j},j});
/*! loglevel - v1.5.0 - https://github.com/pimterry/loglevel - (c) 2017 Tim Perry - licensed MIT */
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";function a(a,b){var c=a[b];if("function"==typeof c.bind)return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch(b){return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function b(b){return"debug"===b&&(b="log"),typeof console!==h&&(void 0!==console[b]?a(console,b):void 0!==console.log?a(console,"log"):g)}function c(a,b){for(var c=0;c<i.length;c++){var d=i[c];this[d]=c<a?g:this.methodFactory(d,a,b)}this.log=this.debug}function d(a,b,d){return function(){typeof console!==h&&(c.call(this,b,d),this[a].apply(this,arguments))}}function e(a,c,e){return b(a)||d.apply(this,arguments)}function f(a,b,d){function f(a){var b=(i[a]||"silent").toUpperCase();if(typeof window!==h){try{return void(window.localStorage[l]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(l)+"="+b+";"}catch(a){}}}function g(){var a;if(typeof window!==h){try{a=window.localStorage[l]}catch(a){}if(typeof a===h)try{var b=window.document.cookie,c=b.indexOf(encodeURIComponent(l)+"=");c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}return void 0===k.levels[a]&&(a=void 0),a}}var j,k=this,l="loglevel";a&&(l+=":"+a),k.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},k.methodFactory=d||e,k.getLevel=function(){return j},k.setLevel=function(b,d){if("string"==typeof b&&void 0!==k.levels[b.toUpperCase()]&&(b=k.levels[b.toUpperCase()]),!("number"==typeof b&&b>=0&&b<=k.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(j=b,!1!==d&&f(b),c.call(k,b,a),typeof console===h&&b<k.levels.SILENT)return"No console available for logging"},k.setDefaultLevel=function(a){g()||k.setLevel(a,!1)},k.enableAll=function(a){k.setLevel(k.levels.TRACE,a)},k.disableAll=function(a){k.setLevel(k.levels.SILENT,a)};var m=g();null==m&&(m=null==b?"WARN":b),k.setLevel(m,!1)}var g=function(){},h="undefined",i=["trace","debug","info","warn","error"],j=new f,k={};j.getLogger=function(a){if("string"!=typeof a||""===a)throw new TypeError("You must supply a name when creating a logger.");var b=k[a];return b||(b=k[a]=new f(a,j.getLevel(),j.methodFactory)),b};var l=typeof window!==h?window.log:void 0;return j.noConflict=function(){return typeof window!==h&&window.log===j&&(window.log=l),j},j});

@@ -51,3 +51,3 @@ 'use strict';

context: {
src: 'test/test-context-using-apply.test.js',
src: 'test/test-context-using-apply.generated.js',
options: {

@@ -166,3 +166,3 @@ specs: 'test/global-integration-with-new-context.js',

},
src: ['test/*.js']
src: ['test/*.js', '!test/*.generated.js']
}

@@ -177,7 +177,7 @@ },

files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'jasmine']
tasks: ['jshint:lib', 'test']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'jasmine']
tasks: ['jshint:test', 'test']
}

@@ -191,7 +191,7 @@ },

src: 'test/test-context-using-apply.js',
dest: 'test/test-context-using-apply.test.js'
dest: 'test/test-context-using-apply.generated.js'
}
},
clean:{
test:['test/test-context-using-apply.test.js']
test:['test/test-context-using-apply.generated.js']
}

@@ -198,0 +198,0 @@ });

@@ -18,17 +18,16 @@ /*

"use strict";
// Slightly dubious tricks to cut down minimized file size
var noop = function() {};
var undefinedType = "undefined";
function realMethod(methodName) {
if (typeof console === undefinedType) {
return false; // We can't build a real method without a console to log to
} else if (console[methodName] !== undefined) {
return bindMethod(console, methodName);
} else if (console.log !== undefined) {
return bindMethod(console, 'log');
} else {
return noop;
}
}
var logMethods = [
"trace",
"debug",
"info",
"warn",
"error"
];
// Cross-browser bind equivalent that works at least back to IE6
function bindMethod(obj, methodName) {

@@ -50,13 +49,22 @@ var method = obj[methodName];

// these private functions always need `this` to be set properly
// Build the best logging method possible for this env
// Wherever possible we want to bind, not wrap, to preserve stack traces
function realMethod(methodName) {
if (methodName === 'debug') {
methodName = 'log';
}
function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
return function () {
if (typeof console !== undefinedType) {
replaceLoggingMethods.call(this, level, loggerName);
this[methodName].apply(this, arguments);
}
};
if (typeof console === undefinedType) {
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
} else if (console[methodName] !== undefined) {
return bindMethod(console, methodName);
} else if (console.log !== undefined) {
return bindMethod(console, 'log');
} else {
return noop;
}
}
// These private functions always need `this` to be set properly
function replaceLoggingMethods(level, loggerName) {

@@ -70,4 +78,20 @@ /*jshint validthis:true */

}
// Define log.log as an alias for log.debug
this.log = this.debug;
}
// In old IE versions, the console isn't present until you first open it.
// We build realMethod() replacements here that regenerate logging methods
function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
return function () {
if (typeof console !== undefinedType) {
replaceLoggingMethods.call(this, level, loggerName);
this[methodName].apply(this, arguments);
}
};
}
// By default, we use closely bound real methods wherever possible, and
// otherwise we wait for a console to appear, and then try again.
function defaultMethodFactory(methodName, level, loggerName) {

@@ -79,10 +103,2 @@ /*jshint validthis:true */

var logMethods = [
"trace",
"debug",
"info",
"warn",
"error"
];
function Logger(name, defaultLevel, factory) {

@@ -99,2 +115,4 @@ var self = this;

if (typeof window === undefinedType) return;
// Use localStorage if available

@@ -116,2 +134,4 @@ try {

if (typeof window === undefinedType) return;
try {

@@ -121,2 +141,3 @@ storedLevel = window.localStorage[storageKey];

// Fallback to cookies if local storage gives us nothing
if (typeof storedLevel === undefinedType) {

@@ -143,3 +164,3 @@ try {

*
* Public API
* Public logger API - see https://github.com/pimterry/loglevel for details
*

@@ -199,3 +220,3 @@ */

*
* Package-level API
* Top-level API
*

@@ -202,0 +223,0 @@ */

{
"name": "loglevel",
"description": "Minimal lightweight logging for JavaScript, adding reliable log level methods to any available console.log methods",
"version": "1.4.1",
"version": "1.5.0",
"homepage": "https://github.com/pimterry/loglevel",

@@ -25,3 +25,5 @@ "author": {

"test": "grunt test",
"ci": "grunt ci"
"ci": "grunt ci",
"dist": "grunt dist",
"watch": "grunt watch"
},

@@ -32,17 +34,17 @@ "dependencies": {},

"grunt-cli": "~0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-connect": "~0.8.0",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-contrib-uglify": "~0.5.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-template-jasmine-requirejs": "~0.1.6",
"grunt-template-jasmine-istanbul": "~0.2.5",
"grunt-coveralls": "^1.0.0",
"grunt-jasmine-node": "~0.2.1",
"grunt-open": "~0.2.3",
"grunt-preprocess": "^4.0.0",
"grunt-saucelabs": "^8.2.0",
"grunt-contrib-connect": "~0.8.0",
"grunt-jasmine-node": "~0.2.1",
"grunt-coveralls": "^1.0.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-preprocess": "^4.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-template-jasmine-istanbul": "~0.2.5",
"grunt-template-jasmine-requirejs": "~0.1.6",
"qunitjs": "1.14.0"

@@ -49,0 +51,0 @@ },

# loglevel [![NPM Version][npm-image]][npm-url] [![Build Status](https://travis-ci.org/pimterry/loglevel.png)](https://travis-ci.org/pimterry/loglevel) [![Coverage Status](https://coveralls.io/repos/pimterry/loglevel/badge.png?branch=master)](https://coveralls.io/r/pimterry/loglevel?branch=master)
# loglevel [![NPM version][npm-image]][npm-url] [![NPM downloads](https://img.shields.io/npm/dw/loglevel.svg)](https://www.npmjs.com/package/loglevel) [![Build status](https://travis-ci.org/pimterry/loglevel.png)](https://travis-ci.org/pimterry/loglevel) [![Coveralls percentage](https://img.shields.io/coveralls/pimterry/loglevel.svg)](https://coveralls.io/r/pimterry/loglevel?branch=master)

@@ -75,2 +75,9 @@

### As an ES6 module (assuming some transpilation step):
```javascript
import * as log from 'loglevel';
log.debug("all done");
```
### With noConflict():

@@ -102,2 +109,4 @@

`log.log(msg)` is also available, as an alias for `log.debug(msg)`, to improve compatibility with `console`, and make migration easier.
Exact output formatting of these will depend on the console available in the current context of your application. For example, many environments will include a full stack trace with all trace() calls, and icons or similar to highlight other calls.

@@ -198,2 +207,6 @@

[loglevel-plugin-prefix](https://github.com/kutuluk/loglevel-plugin-prefix) - plugin for loglevel message prefixing.
[loglevel-plugin-remote](https://github.com/kutuluk/loglevel-plugin-remote) - plugin for sending loglevel messages to a remote log server.
ServerSend - https://github.com/artemyarulin/loglevel-serverSend - Forward your log messages to a remote server.

@@ -205,2 +218,4 @@

Message Buffer - https://github.com/NatLibFi/loglevel-message-buffer - Buffer messages, and flush them on-demand later.
DEBUG - https://github.com/vectrlabs/loglevel-debug - Control logging from a DEBUG environmental variable (similar to the classic [Debug](https://github.com/visionmedia/debug) module)

@@ -237,3 +252,3 @@

Builds can be run with grunt: run `grunt dist` to build a distributable version of the project (in /dist), or `grunt test` to just run the tests and linting. During development you can run `grunt watch` and it will monitor source files, and rerun the tests and linting as appropriate when they're changed.
Builds can be run with npm: run `npm run dist` to build a distributable version of the project (in /dist), or `npm test` to just run the tests and linting. During development you can run `npm run watch` and it will monitor source files, and rerun the tests and linting as appropriate when they're changed.

@@ -247,3 +262,3 @@ _Also, please don't manually edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "lib" subdirectory!_

* Update the version number in package.json and bower.json
* Run `grunt dist` to build a distributable version in dist/
* Run `npm run dist` to build a distributable version in dist/
* Update the release history in this file (below)

@@ -286,4 +301,6 @@ * Commit the built code, tagging it with the version number and a brief message about the release

v1.5.0 - Fix log.debug (#111) after V8 changes deprecating console.debug, check for `window` upfront (#104), and add `.log` alias for `.debug` (#64)
## License
Copyright (c) 2013 Tim Perry
Copyright (c) 2013 Tim Perry
Licensed under the MIT license.

@@ -0,0 +0,0 @@ /* global MyCustomLogger, log */

@@ -0,0 +0,0 @@ /* global log */

@@ -13,2 +13,3 @@ "use strict";

log.debug("debug");
log.log("log");
log.info("info");

@@ -28,2 +29,3 @@ log.warn("warn");

log.debug("debug");
log.log("log");
log.info("info");

@@ -30,0 +32,0 @@ log.warn("warn");

@@ -11,2 +11,10 @@ "use strict";

function getConsoleMethod(logMethodName) {
if (logMethodName === 'debug') {
return console.log;
} else {
return console[logMethodName];
}
}
define(['../lib/loglevel'], function(log) {

@@ -22,2 +30,4 @@ var originalConsole = window.console;

}
window.console.log = jasmine.createSpy('log');
});

@@ -37,3 +47,3 @@

expect(console[method]).toHaveBeenCalled();
expect(getConsoleMethod(method)).toHaveBeenCalled();
}

@@ -51,3 +61,3 @@ });

expect(console[method]).not.toHaveBeenCalled();
expect(getConsoleMethod(method)).not.toHaveBeenCalled();
}

@@ -95,3 +105,3 @@ });

log[level]("log message");
expect(console[level]).toHaveBeenCalled();
expect(getConsoleMethod(level)).toHaveBeenCalled();
});

@@ -136,3 +146,3 @@ }

log.debug("a log message");
expect(console.debug).toHaveBeenCalled();
expect(console.log).toHaveBeenCalled();
});

@@ -144,3 +154,3 @@

log.debug("a log message");
expect(console.debug).toHaveBeenCalled();
expect(console.log).toHaveBeenCalled();
});

@@ -152,3 +162,3 @@

log.debug("a log message");
expect(console.debug).not.toHaveBeenCalled();
expect(console.log).not.toHaveBeenCalled();
});

@@ -160,6 +170,36 @@

log.debug("a log message");
expect(console.debug).not.toHaveBeenCalled();
expect(console.log).not.toHaveBeenCalled();
});
});
describe("log.log", function() {
it("is enabled at trace level", function() {
log.setLevel(log.levels.TRACE);
log.log("a log message");
expect(console.log).toHaveBeenCalled();
});
it("is enabled at debug level", function() {
log.setLevel(log.levels.DEBUG);
log.log("a log message");
expect(console.log).toHaveBeenCalled();
});
it("is disabled at info level", function() {
log.setLevel(log.levels.INFO);
log.log("a log message");
expect(console.log).not.toHaveBeenCalled();
});
it("is disabled at silent level", function() {
log.setLevel(log.levels.SILENT);
log.log("a log message");
expect(console.log).not.toHaveBeenCalled();
});
});
describe("log.info", function() {

@@ -166,0 +206,0 @@ it("is enabled at debug level", function() {

@@ -0,0 +0,0 @@ "use strict";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc