Comparing version 2.4.1 to 2.4.2
'use strict'; | ||
/** | ||
* @typedef {(...args: any) => void} LogFunction | ||
*/ | ||
/** | ||
* @typedef {object} AbstractLogger | ||
* @property {LogFunction} trace | ||
* @property {LogFunction} debug | ||
* @property {LogFunction} info | ||
* @property {LogFunction} warn | ||
* @property {LogFunction} error | ||
* @property {LogFunction} fatal | ||
*/ | ||
const NoopLog = require('nooplog'); | ||
const utils = require('./utils'); | ||
/** | ||
* Returns an abstract logger which enables adding logging to modules without adding a dependency to a full log library. | ||
* @param {any} logger | ||
* @returns {AbstractLogger} | ||
*/ | ||
module.exports = function abslog(logger) { | ||
@@ -7,0 +26,0 @@ if (Object.is(logger, console)) { |
@@ -9,5 +9,6 @@ 'use strict'; | ||
* we log to console.log for debug instead. | ||
*/ | ||
*/ | ||
const consoleLogger = { | ||
// @ts-ignore | ||
fatal: console.fatal ? console.fatal : console.log, | ||
@@ -22,3 +23,3 @@ error: console.error ? console.error : console.log, | ||
function validateMethod(method) { | ||
return (method && {}.toString.call(method) === '[object Function]'); | ||
return method && {}.toString.call(method) === '[object Function]'; | ||
} | ||
@@ -34,3 +35,5 @@ | ||
if (!validateMethod(logger[methods[i]])) { | ||
throw new TypeError(`Provided logger is not API compliant. Missing "${methods[i]}" method.`); | ||
throw new TypeError( | ||
`Provided logger is not API compliant. Missing "${methods[i]}" method.`, | ||
); | ||
} | ||
@@ -37,0 +40,0 @@ } |
{ | ||
"name": "abslog", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "An abstract logger - Enables adding logging to modules without adding a dependency to a full log library. ", | ||
@@ -12,3 +12,5 @@ "main": "lib/log.js", | ||
"scripts": { | ||
"prepublish": "npm run types", | ||
"test": "tap test/*.js --disable-coverage", | ||
"types": "tsc", | ||
"lint": "eslint .", | ||
@@ -55,3 +57,4 @@ "lint:fix": "eslint . --fix" | ||
"logdna": "3.5.3", | ||
"synclog": "1.0.1" | ||
"synclog": "1.0.1", | ||
"typescript": "5.4.5" | ||
}, | ||
@@ -58,0 +61,0 @@ "dependencies": { |
@@ -1,16 +0,14 @@ | ||
export type LogFunction = (...args: any) => void; | ||
/** | ||
* An abstract logger which enables adding logging to modules without adding a dependency to a full log library | ||
*/ | ||
export type AbstractLogger = { | ||
trace: LogFunction, | ||
debug: LogFunction, | ||
info: LogFunction, | ||
warn: LogFunction, | ||
error: LogFunction, | ||
fatal: LogFunction | ||
declare namespace _exports { | ||
export { LogFunction, AbstractLogger }; | ||
} | ||
declare function abstractLogger(logger: any): AbstractLogger; | ||
export default abstractLogger; | ||
declare function _exports(logger: any): AbstractLogger; | ||
export = _exports; | ||
type LogFunction = (...args: any) => void; | ||
type AbstractLogger = { | ||
trace: LogFunction; | ||
debug: LogFunction; | ||
info: LogFunction; | ||
warn: LogFunction; | ||
error: LogFunction; | ||
fatal: LogFunction; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11534
7
87
0
15