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

abslog

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abslog - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

5

lib/log.js
'use strict';
const { Console } = require('console');
const NoopLog = require('nooplog');
const utils = require('./utils');
const { Console } = require('console');

@@ -10,3 +11,3 @@ module.exports = function abslog(logger) {

}
return utils.validateLogger(logger) ? logger : Object.create(utils.noopLogger);
return utils.validateLogger(logger) ? logger : new NoopLog();
};
'use strict';
function noop() {}
const noopLogger = {
fatal: noop,
error: noop,
warn: noop,
info: noop,
debug: noop,
trace: noop
};
const consoleLogger = {

@@ -42,5 +31,4 @@ fatal: console.fatal ? console.fatal : console.log,

module.exports.noopLogger = noopLogger;
module.exports.consoleLogger = consoleLogger;
module.exports.validateMethod = validateMethod;
module.exports.validateLogger = validateLogger;
{
"name": "abslog",
"version": "1.3.0",
"version": "2.0.0",
"description": "An abstract logger - Enables adding logging to modules without adding a dependency to a full log library. ",

@@ -44,3 +44,6 @@ "main": "lib/log.js",

"pino": "^4.13.0"
},
"dependencies": {
"nooplog": "^1.0.0"
}
}

17

test/utils.js
'use strict';
const NoopLog = require('nooplog');
const utils = require('../lib/utils');

@@ -9,16 +10,2 @@ const tap = require('tap');

/**
* utils.noopLogger
*/
tap.test('utils.noopLogger - Object - should have "fatal", "error", "warn", "info", "debug" and "trace" methods', (t) => {
t.true(utils.validateMethod(utils.noopLogger.fatal));
t.true(utils.validateMethod(utils.noopLogger.error));
t.true(utils.validateMethod(utils.noopLogger.warn));
t.true(utils.validateMethod(utils.noopLogger.info));
t.true(utils.validateMethod(utils.noopLogger.debug));
t.true(utils.validateMethod(utils.noopLogger.trace));
t.end();
});
/**
* utils.consoleLogger

@@ -69,3 +56,3 @@ */

tap.test('utils.validateLogger() - logger is compliant - should return "true"', (t) => {
t.true(utils.validateLogger(Object.create(utils.noopLogger)));
t.true(utils.validateLogger(new NoopLog()));
t.true(utils.validateLogger(Object.create(utils.consoleLogger)));

@@ -72,0 +59,0 @@ t.end();

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