Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bv-ui-core

Package Overview
Dependencies
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bv-ui-core - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

17

lib/logger/index.js

@@ -26,3 +26,3 @@ /*jshint expr:true */

var logLevel = 1; // Default to INFO.
var logLevel = 4; // Default to OFF.

@@ -61,4 +61,11 @@ /**

setLogLevel: function (level) {
logLevel = level || Logger.LOG;
/**
* Only sets the log level if there is no cookie or if passed a force param.
* @param {[type]} level logLevel
* @param {[type]} force arg to force setting level to the level arg
*/
setLogLevel: function (level, force) {
logLevel = (!cookieObj.logLevel || force) ?
(level|| Logger.LOG) :
cookieObj.logLevel;
logger('log', [ 'Log level set to', logLevel ]);

@@ -100,3 +107,3 @@ },

group: function (maxLevel) {
var args = arguments.slice(1);
var args = Array.prototype.slice.call(arguments, 1);
if (logLevel <= maxLevel) {

@@ -109,3 +116,3 @@ logger('group', args);

groupEnd: function (maxLevel) {
var args = arguments.slice(1);
var args = Array.prototype.slice.call(arguments, 1);
if (logLevel <= maxLevel) {

@@ -112,0 +119,0 @@ logger('groupEnd', args);

# logger
The `logger` module provides an object that wraps various console logging methods safely. The default level is INFO, but it is recommended that you set this according to your environment either at build time or by a cookie in the browser in the format `_bvui_debug=loglevel:4`.
The `logger` module provides an object that wraps various console logging methods safely. The default level is OFF, but it is recommended that you set this according to your environment either at build time or by a cookie in the browser in the format `_bvui_debug=loglevel:1`.

@@ -40,2 +40,8 @@ ## Usage

If you have set the logLevel via cookie, any calls to `setLogLevel` in your application will be ignored unless you also pass a force param.
```javascript
setLogLevel(Logger.LOG, true); // forces LogLevel to LOG
```
### Logger.group/Logger.groupEnd

@@ -66,2 +72,2 @@ https://developer.mozilla.org/en-US/docs/Web/API/console/group

javascript:(function() { var val = prompt('Enter log level (From -1 to 4)'); if (!val && val !== 0) { return; } document.cookie='_bvui_debug=logLevel:' + val; }());
```
```
{
"name": "bv-ui-core",
"version": "0.7.0",
"version": "0.8.0",
"license": "Apache 2.0",

@@ -31,2 +31,3 @@ "description": "Bazaarvoice UI-related JavaScript",

"karma-webpack": "1.7.0",
"mocha": "2.3.4",
"node-libs-browser": "0.5.2",

@@ -33,0 +34,0 @@ "phantomjs": "1.9.18",

@@ -49,2 +49,3 @@ ![](https://magnum.travis-ci.com/bazaarvoice/bv-ui-core.svg?token=hwKyg8j4RFg7BgmSksac&branch=master)

- [loader](./lib/loader)
- [logger](./lib/logger)
- [namespacer](./lib/namespacer)

@@ -51,0 +52,0 @@ - [parseUri](./lib/parseUri)

@@ -14,3 +14,5 @@ /**

warnStub,
errorStub;
errorStub,
groupStub,
groupEndStub;

@@ -23,2 +25,4 @@ before(function () {

errorStub = sinon.stub(console, 'error');
groupStub = sinon.stub(console, 'group');
groupEndStub = sinon.stub(console, 'groupEnd');
});

@@ -32,2 +36,4 @@

errorStub.reset();
groupStub.reset();
groupEndStub.reset();

@@ -39,4 +45,7 @@ // reset the log level to the default

it('works', function () {
Logger.info('hi');
expect(infoStub).to.have.been.calledWith('hi');
Logger.info('Hello');
expect(infoStub).not.to.have.been.called;
Logger.setLogLevel(Logger.INFO, true);
Logger.info('World');
expect(infoStub).to.have.been.calledWith('World');
});

@@ -110,2 +119,36 @@

})
})
describe('#group', function () {
it('calls console.group if maxLevel is < the current log level', function () {
Logger.group(Logger.INFO);
expect(groupStub).to.have.been.called;
});
it('does not call console.group if maxLevel is < the current log level', function () {
Logger.group(Logger.DEBUG);
expect(groupStub).to.not.have.been.called;
});
it('passes arguments on to console.group', function () {
Logger.group(Logger.INFO, 'Test Group');
expect(groupStub).to.have.been.calledWith('Test Group');
});
});
describe('#groupEnd', function () {
it('calls console.groupEnd if maxLevel is < the current log level', function () {
Logger.groupEnd(Logger.INFO);
expect(groupEndStub).to.have.been.called;
});
it('does not call console.groupEnd if maxLevel is < the current log level', function () {
Logger.groupEnd(Logger.DEBUG);
expect(groupEndStub).to.not.have.been.called;
});
it('passes arguments on to console.groupEnd', function () {
Logger.groupEnd(Logger.INFO, 'Test GroupEnd');
expect(groupEndStub).to.have.been.calledWith('Test GroupEnd');
});
});
})

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