Comparing version 1.3.0 to 2.0.0
'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" | ||
} | ||
} |
'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(); |
18661
1
356
+ Addednooplog@^1.0.0
+ Addednooplog@1.0.2(transitive)