Socket
Socket
Sign inDemoInstall

loglevel

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loglevel - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

CONTRIBUTING.md

2

bower.json
{
"name": "loglevel",
"version": "0.5.0",
"version": "0.6.0",
"main": "dist/loglevel.min.js",

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

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

/*! loglevel - v0.5.0 - https://github.com/pimterry/loglevel - (c) 2013 Tim Perry - licensed MIT */
/*! loglevel - v0.6.0 - https://github.com/pimterry/loglevel - (c) 2014 Tim Perry - licensed MIT */
;(function (undefined) {

@@ -85,3 +85,4 @@ var undefinedType = "undefined";

function persistLevelIfPossible(levelNum) {
var levelName;
var localStorageFail = false,
levelName;

@@ -96,8 +97,19 @@ for (var key in self.levels) {

if (localStorageAvailable()) {
window.localStorage['loglevel'] = levelName;
} else if (cookiesAvailable()) {
window.document.cookie = "loglevel=" + levelName + ";";
/*
* Setting localStorage can create a DOM 22 Exception if running in Private mode
* in Safari, so even if it is available we need to catch any errors when trying
* to write to it
*/
try {
window.localStorage['loglevel'] = levelName;
} catch (e) {
localStorageFail = true;
}
} else {
return;
localStorageFail = true;
}
if (localStorageFail && cookiesAvailable()) {
window.document.cookie = "loglevel=" + levelName + ";";
}
}

@@ -114,8 +126,12 @@

if (!storedLevel && cookiesAvailable()) {
if (storedLevel === undefined && cookiesAvailable()) {
var cookieMatch = cookieRegex.exec(window.document.cookie) || [];
storedLevel = cookieMatch[1];
}
if (self.levels[storedLevel] === undefined) {
storedLevel = "WARN";
}
self.setLevel(self.levels[storedLevel] || self.levels.WARN);
self.setLevel(self.levels[storedLevel]);
}

@@ -122,0 +138,0 @@

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

/*! loglevel - v0.5.0 - https://github.com/pimterry/loglevel - (c) 2013 Tim Perry - licensed MIT */
!function(a){var b="undefined";!function(a,b){"undefined"!=typeof module?module.exports=b():"function"==typeof define&&"object"==typeof define.amd?define(b):this[a]=b()}("log",function(){function c(c){return typeof console===b?l:console[c]===a?console.log!==a?d(console,"log"):l:d(console,c)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b<m.length;b++)k[m[b]]=a(m[b])}function g(){return typeof window!==b&&window.document!==a&&window.document.cookie!==a}function h(){try{return typeof window!==b&&window.localStorage!==a}catch(c){return!1}}function i(a){var b;for(var c in k.levels)if(k.levels.hasOwnProperty(c)&&k.levels[c]===a){b=c;break}if(h())window.localStorage.loglevel=b;else{if(!g())return;window.document.cookie="loglevel="+b+";"}}function j(){var a;if(h()&&(a=window.localStorage.loglevel),!a&&g()){var b=n.exec(window.document.cookie)||[];a=b[1]}k.setLevel(k.levels[a]||k.levels.WARN)}var k={},l=function(){},m=["trace","debug","info","warn","error"],n=/loglevel=([^;]+)/;return k.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},k.setLevel=function(d){if("number"==typeof d&&d>=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return f(function(){return l}),void 0;if(typeof console===b)return f(function(a){return function(){typeof console!==b&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?c(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}();
/*! loglevel - v0.6.0 - https://github.com/pimterry/loglevel - (c) 2014 Tim Perry - licensed MIT */
!function(a){var b="undefined";!function(a,b){"undefined"!=typeof module?module.exports=b():"function"==typeof define&&"object"==typeof define.amd?define(b):this[a]=b()}("log",function(){function c(c){return typeof console===b?l:console[c]===a?console.log!==a?d(console,"log"):l:d(console,c)}function d(b,c){var d=b[c];if(d.bind!==a)return b[c].bind(b);if(Function.prototype.bind===a)return e(d,b);try{return Function.prototype.bind.call(b[c],b)}catch(f){return e(d,b)}}function e(a,b){return function(){Function.prototype.apply.apply(a,[b,arguments])}}function f(a){for(var b=0;b<m.length;b++)k[m[b]]=a(m[b])}function g(){return typeof window!==b&&window.document!==a&&window.document.cookie!==a}function h(){try{return typeof window!==b&&window.localStorage!==a}catch(c){return!1}}function i(a){var b,c=!1;for(var d in k.levels)if(k.levels.hasOwnProperty(d)&&k.levels[d]===a){b=d;break}if(h())try{window.localStorage.loglevel=b}catch(e){c=!0}else c=!0;c&&g()&&(window.document.cookie="loglevel="+b+";")}function j(){var b;if(h()&&(b=window.localStorage.loglevel),b===a&&g()){var c=n.exec(window.document.cookie)||[];b=c[1]}k.levels[b]===a&&(b="WARN"),k.setLevel(k.levels[b])}var k={},l=function(){},m=["trace","debug","info","warn","error"],n=/loglevel=([^;]+)/;return k.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},k.setLevel=function(d){if("number"==typeof d&&d>=0&&d<=k.levels.SILENT){if(i(d),d===k.levels.SILENT)return void f(function(){return l});if(typeof console===b)return f(function(a){return function(){typeof console!==b&&(k.setLevel(d),k[a].apply(k,arguments))}}),"No console available for logging";f(function(a){return d<=k.levels[a.toUpperCase()]?c(a):l})}else{if("string"!=typeof d||k.levels[d.toUpperCase()]===a)throw"log.setLevel() called with invalid level: "+d;k.setLevel(k.levels[d.toUpperCase()])}},k.enableAll=function(){k.setLevel(k.levels.TRACE)},k.disableAll=function(){k.setLevel(k.levels.SILENT)},j(),k})}();

@@ -49,2 +49,37 @@ 'use strict';

}
},
withCoverage: {
src: 'lib/**/*.js',
options: {
specs: 'test/*-test.js',
vendor: 'test/vendor/*.js',
helpers: 'test/*-helper.js',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'coverage/coverage.json',
report: [
{
type: 'html',
options: {
dir: 'coverage'
}
},
{
type: 'lcov',
options: {
dir: 'coverage'
}
}
],
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
paths: {
"lib": '.grunt/grunt-contrib-jasmine/lib/'
}
}
}
}
}
}

@@ -58,2 +93,5 @@ },

},
coveralls: {
src: 'coverage/lcov.info'
},
open: {

@@ -143,2 +181,3 @@ jasmine: {

grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-jasmine-node');

@@ -155,4 +194,4 @@ grunt.loadNpmTasks('grunt-contrib-jshint');

// Just tests
grunt.registerTask('test', ['jshint', 'jasmine:requirejs', 'jasmine:global', 'jasmine_node']);
// Check everything is good
grunt.registerTask('test', ['jshint', 'jasmine:requirejs', 'jasmine:global', 'jasmine_node', 'jasmine:withCoverage']);

@@ -167,3 +206,4 @@ // Test with a live server and an actual browser

grunt.registerTask('default', 'test');
grunt.registerTask('ci', ['test', 'coveralls']);
};

@@ -91,3 +91,4 @@ /*

function persistLevelIfPossible(levelNum) {
var levelName;
var localStorageFail = false,
levelName;

@@ -102,8 +103,19 @@ for (var key in self.levels) {

if (localStorageAvailable()) {
window.localStorage['loglevel'] = levelName;
} else if (cookiesAvailable()) {
window.document.cookie = "loglevel=" + levelName + ";";
/*
* Setting localStorage can create a DOM 22 Exception if running in Private mode
* in Safari, so even if it is available we need to catch any errors when trying
* to write to it
*/
try {
window.localStorage['loglevel'] = levelName;
} catch (e) {
localStorageFail = true;
}
} else {
return;
localStorageFail = true;
}
if (localStorageFail && cookiesAvailable()) {
window.document.cookie = "loglevel=" + levelName + ";";
}
}

@@ -120,8 +132,12 @@

if (!storedLevel && cookiesAvailable()) {
if (storedLevel === undefined && cookiesAvailable()) {
var cookieMatch = cookieRegex.exec(window.document.cookie) || [];
storedLevel = cookieMatch[1];
}
if (self.levels[storedLevel] === undefined) {
storedLevel = "WARN";
}
self.setLevel(self.levels[storedLevel] || self.levels.WARN);
self.setLevel(self.levels[storedLevel]);
}

@@ -128,0 +144,0 @@

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

@@ -29,18 +29,21 @@ "author": {

"scripts": {
"test": "grunt test"
"test": "grunt test",
"ci": "grunt ci"
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.9",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-watch": "~0.5.1",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-template-jasmine-requirejs": "~0.1.6",
"grunt-open": "~0.2.2",
"grunt-saucelabs": "~4.1.2",
"grunt-contrib-connect": "~0.5.0",
"grunt-jasmine-node": "~0.1.0"
"grunt": "^0.4.1",
"grunt-cli": "^0.1.9",
"grunt-contrib-concat": "^0.3.0",
"grunt-contrib-uglify": "^0.3.0",
"grunt-contrib-jshint": "^0.8.0",
"grunt-contrib-watch": "^0.5.1",
"grunt-contrib-jasmine": "^0.5.2",
"grunt-template-jasmine-requirejs": "^0.1.6",
"grunt-template-jasmine-istanbul": "^0.2.5",
"grunt-open": "^0.2.2",
"grunt-saucelabs": "^5.0.0",
"grunt-contrib-connect": "^0.6.0",
"grunt-jasmine-node": "^0.1.0",
"grunt-coveralls": "^0.3.0"
},

@@ -47,0 +50,0 @@ "jam": {

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

# loglevel [![Build Status](https://travis-ci.org/pimterry/loglevel.png)](https://travis-ci.org/pimterry/loglevel) [![Dependency status](https://david-dm.org/pimterry/loglevel/dev-status.png)](https://david-dm.org/pimterry/loglevel#info=devDependencies&view=table)
# loglevel [![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) [![Dependency status](https://david-dm.org/pimterry/loglevel/dev-status.png)](https://david-dm.org/pimterry/loglevel#info=devDependencies&view=table)

@@ -34,3 +34,3 @@ Minimal lightweight simple logging for JavaScript. loglevel replaces console.log() and friends with level-based logging and filtering, with none of console's downsides.

Alternatively if you just want to grab the file yourself, you can download either the current stable [production version][min] or the [development version][max] directly, or reference it remotely on CDNJS at `//cdnjs.cloudflare.com/ajax/libs/loglevel/0.4.0/loglevel.min.js`
Alternatively if you just want to grab the file yourself, you can download either the current stable [production version][min] or the [development version][max] directly, or reference it remotely on CDNJS at `//cdnjs.cloudflare.com/ajax/libs/loglevel/0.5.0/loglevel.min.js`

@@ -87,3 +87,3 @@ Finally, if you want to tweak loglevel to your own needs or you immediately need the cutting-edge version, clone this repo and see [Developing & Contributing](#developing--contributing) below for build instructions.

This disables all logging below the given level, so that after a log.setLevel("warn) call log.warn("something") or log.error("something") will output messages, but log.info("something") will not.
This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something") or log.error("something") will output messages, but log.info("something") will not.

@@ -121,2 +121,3 @@ This can take either a log level name or 'silent' (which disables everything) in one of a few forms:

* Run `jam publish` to publish to JamJS
* Autoupdate gh-pages docs
* Open a pull request to https://github.com/cdnjs/cdnjs to put the new release on the CDN

@@ -137,2 +138,4 @@

v0.6.0 - Handle logging in Safari private browsing mode (#33), fix TRACE level persistence bug (#35), plus various minor tweaks
## License

@@ -143,1 +146,5 @@ Copyright (c) 2013 Tim Perry

[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/3393271900ddc6808ae1901f3760a59e)](http://githalytics.com/pimterry/loglevel)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pimterry/loglevel/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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

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

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

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

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

@@ -47,3 +47,23 @@ "use strict";

});
describe("If trace level is saved", function () {
beforeEach(function () {
testHelpers.setStoredLevel("trace");
});
it("trace is the default log level", function (log) {
expect(log).toBeAtLevel("trace");
});
});
describe("If debug level is saved", function () {
beforeEach(function () {
testHelpers.setStoredLevel("debug");
});
it("debug is the default log level", function (log) {
expect(log).toBeAtLevel("debug");
});
});
describe("If info level is saved", function() {

@@ -71,2 +91,23 @@ beforeEach(function() {

describe("If warn level is saved", function () {
beforeEach(function () {
testHelpers.setStoredLevel("warn");
});
it("warn is the default log level", function (log) {
expect(log).toBeAtLevel("warn");
});
});
describe("If error level is saved", function () {
beforeEach(function () {
testHelpers.setStoredLevel("error");
});
it("error is the default log level", function (log) {
expect(log).toBeAtLevel("error");
});
});
describe("If the level is saved with other data", function() {

@@ -73,0 +114,0 @@ beforeEach(function() {

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

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

@@ -0,0 +0,0 @@ /*

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc