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 2.4.1 to 2.4.2

types/utils.d.ts

19

lib/log.js
'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

lib/utils.js

@@ -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;
};
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