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

plylog

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plylog - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

41

index.js

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

let consoleTransport = new (winston.transports.Console)({
level: options.level || 'info'
level: options.level || 'info',
label: options.name || null,
});

@@ -103,2 +104,38 @@ this._logger = new (winston.Logger)({transports: [consoleTransport]});

module.exports = PolymerLogger;
module.exports = {
configOptions: {},
/**
* Set all future loggers created, across the application, to be verbose.
*
* @return {void}
*/
setVerbose: function() {
this.configOptions.level = 'debug';
},
/**
* Set all future loggers created, across the application, to be quiet.
*
* @return {void}
*/
setQuiet: function() {
this.configOptions.level = 'error';
},
/**
* Create a new logger with the given name label. It will inherit the global
* level if one has been set within the application.
*
* @param {string} name The name of the logger, useful for grouping messages
* @return {PolymerLogger}
*/
getLogger: function(name) {
return new PolymerLogger({
level: this.configOptions.level,
name: name,
});
},
};

2

package.json
{
"name": "plylog",
"version": "0.0.1",
"version": "0.0.2",
"description": "A logger for the Polymer CLI toolchain",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,31 +16,60 @@ /**

const sinon = require('sinon');
const PolymerLogger = require('../index.js');
const logging = require('../index.js');
suite('plylog', () => {
test('creates an internal winston logger with the given logger when instantiated', () => {
let logger = new PolymerLogger({level: 'warn'});
assert.instanceOf(logger._logger, winston.Logger);
suite('getLogger()', () => {
test('creates an internal winston logger with the given logger when instantiated', () => {
let logger = logging.getLogger('TEST_LOGGER');
assert.instanceOf(logger._logger, winston.Logger);
});
});
test('changes its internal logger\'s level when setLevel() is called', () => {
let logger = new PolymerLogger({level: 'error'});
assert.equal(logger._logger.transports.console.level, 'error');
logger.setLevel('debug');
assert.equal(logger._logger.transports.console.level, 'debug');
suite('setVerbose()', () => {
test('sets the level of all future loggers to "debug"', () => {
logging.setVerbose();
let logger = logging.getLogger('TEST_LOGGER');
assert.equal(logger._logger.transports.console.level, 'debug');
});
});
test('properly passes arguments to its internal logger\'s log methods when called', () => {
let logger = new PolymerLogger({level: 'emerg'});
let winstonSpy = sinon.spy(logger._logger, 'log');
logger.debug('hello:debug');
assert.isOk(winstonSpy.calledWith('debug', 'hello:debug'));
logger.info('hello:info');
assert.isOk(winstonSpy.calledWith('info', 'hello:info'));
logger.warn('hello:warn');
assert.isOk(winstonSpy.calledWith('warn', 'hello:warn'));
logger.error('hello:error', {metadata: 'foobar'});
assert.isOk(winstonSpy.calledWithMatch('error', 'hello:error', {metadata: 'foobar'}));
suite('setQuiet()', () => {
test('sets the level of all future loggers to "error"', () => {
logging.setQuiet();
let logger = logging.getLogger('TEST_LOGGER');
assert.equal(logger._logger.transports.console.level, 'error');
});
});
suite('PolymerLogger instance', () => {
test('changes its internal logger\'s level when setLevel() is called', () => {
let logger = logging.getLogger('TEST_LOGGER');
logger.setLevel('info');
assert.equal(logger._logger.transports.console.level, 'info');
logger.setLevel('debug');
assert.equal(logger._logger.transports.console.level, 'debug');
});
test('loggers properly pass arguments to their internal logger\'s log methods when called', () => {
let logger = logging.getLogger('TEST_LOGGER');
let winstonSpy = sinon.spy(logger._logger, 'log');
logger.debug('hello:debug');
assert.isOk(winstonSpy.calledWith('debug', 'hello:debug'));
logger.info('hello:info');
assert.isOk(winstonSpy.calledWith('info', 'hello:info'));
logger.warn('hello:warn');
assert.isOk(winstonSpy.calledWith('warn', 'hello:warn'));
logger.error('hello:error', {metadata: 'foobar'});
assert.isOk(winstonSpy.calledWithMatch('error', 'hello:error', {metadata: 'foobar'}));
});
});
});
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