New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dotcom-reliability-kit/logger

Package Overview
Dependencies
Maintainers
0
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcom-reliability-kit/logger - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

types/index.d.ts

12

lib/index.js

@@ -5,15 +5,5 @@ const Logger = require('./logger');

/**
* @typedef {object} Transforms
* @property {legacyMask} legacyMask
* The legacy mask logger.
* @import { DefaultLogger, Transforms } from '@dotcom-reliability-kit/logger'
*/
/**
* @typedef {object} DefaultLogger
* @property {typeof Logger} Logger
* The Logger class.
* @property {Transforms} transforms
* Built-in log transforms.
*/
/** @type {Transforms} */

@@ -20,0 +10,0 @@ const transforms = { legacyMask };

@@ -7,67 +7,16 @@ const pino = require('pino').default;

/**
* @typedef {"silly" | "data" | "debug" | "verbose" | "info" | "warn" | "error" | "fatal"} LogLevel
* @import {
* BaseLogData,
* LogData,
* LoggerInterface,
* LoggerOptions,
* LogLevel,
* LogLevelInfo,
* LogTransform,
* LogTransport,
* PrivateLoggerOptions
* } from '../types/logger';
*/
/**
* @typedef {string | object | Error} LogData
*/
/**
* @typedef {typeof import('pino').stdTimeFunctions.isoTime} TimeFn
*/
/**
* @typedef {object} LoggerOptions
* @property {LogData} [baseLogData = {}]
* Base log data which is added to every log output.
* @property {LogLevel} [logLevel = "debug"]
* The maximum log level to output during logging. Logs at levels
* beneath this will be ignored.
* @property {LogTransform[]} [transforms = []]
* Transforms to apply to logs before sending.
* @property {boolean} [withPrettifier = true]
* Whether to prettify log output if it's possible.
*/
/**
* @typedef {object} PrivateLoggerOptions
* @property {LogTransport} [_transport]
* A transport used to perform logging. This is only for internal use.
*/
/**
* @callback LogTransform
* @param {{[key: string]: any}} logData
* The log data to transform.
* @returns {{[key: string]: any}}
* Returns the transformed log data.
*/
/**
* @typedef {object} LogTransport
* @property {string} [level]
* A property used to set the transport log level.
* @property {(...args: any) => any} debug
* Log debug level information.
* @property {(...args: any) => any} error
* Log error level information.
* @property {(...args: any) => any} fatal
* Log fatal level information.
* @property {(...args: any) => any} info
* Log info level information.
* @property {(...args: any) => any} warn
* Log warn level information.
* @property {() => void} [flush]
* Flush async logs ahead of time.
*/
/**
* @typedef {object} LogLevelInfo
* @property {LogLevel} logLevel
* A canonical alternative level for a given level.
* @property {boolean} isDeprecated
* Whether the original log level is deprecated.
*/
/**
* A map of log levels to the underlying log method that

@@ -131,4 +80,6 @@ * should be called when a log of that level is sent, as

* Class representing a logger.
*
* @implements {LoggerInterface}
*/
class Logger {
module.exports = class Logger {
/**

@@ -140,3 +91,3 @@ * @type {LogLevel}

/**
* @type {LogData}
* @type {BaseLogData}
*/

@@ -246,6 +197,2 @@ #baseLogData = {};

/**
* @public
* @type {LogData}
*/
get baseLogData() {

@@ -255,6 +202,2 @@ return this.#baseLogData;

/**
* @public
* @type {LogLevel}
*/
get logLevel() {

@@ -264,6 +207,2 @@ return this.#logLevel;

/**
* @public
* @type {LogTransport}
*/
get transport() {

@@ -275,8 +214,2 @@ return this.#logTransport;

* Create a child logger with additional base log data.
*
* @public
* @param {LogData} baseLogData
* The base log data to add.
* @returns {Logger}
* Returns a new child logger.
*/

@@ -294,8 +227,2 @@ createChildLogger(baseLogData) {

* Add additional log data to all subsequent log calls.
*
* @deprecated Please create a child logger with `createChildLogger` or use the `baseLogData` option.
* @public
* @param {LogData} extraLogData
* The additional data to add to all logs from this logger.
* @returns {void}
*/

@@ -316,8 +243,2 @@ addContext(extraLogData) {

* Set the `context` property for all subsequent log calls.
*
* @deprecated Please create a child logger with `createChildLogger` or use the `baseLogData` option.
* @public
* @param {LogData} contextData
* The additional data to add to all log `context` properties.
* @returns {void}
*/

@@ -338,6 +259,2 @@ setContext(contextData) {

* Clear the `context` property for all subsequent log calls.
*
* @deprecated Please create a child logger with `createChildLogger` or use the `baseLogData` option.
* @public
* @returns {void}
*/

@@ -358,9 +275,2 @@ clearContext() {

* Send a log.
*
* @public
* @param {LogLevel} level
* The log level to output the log as.
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -428,8 +338,2 @@ log(level, ...logData) {

* Send a log with a level of "data".
*
* @deprecated Please use a log level of "debug" instead.
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -442,7 +346,2 @@ data(...logData) {

* Send a log with a level of "debug".
*
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -455,7 +354,2 @@ debug(...logData) {

* Send a log with a level of "error".
*
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -468,7 +362,2 @@ error(...logData) {

* Send a log with a level of "fatal".
*
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -481,7 +370,2 @@ fatal(...logData) {

* Send a log with a level of "info".
*
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -494,8 +378,2 @@ info(...logData) {

* Send a log with a level of "silly".
*
* @deprecated Please use a log level of "debug" instead.
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -508,8 +386,2 @@ silly(...logData) {

* Send a log with a level of "verbose".
*
* @deprecated Please use a log level of "debug" instead.
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -522,7 +394,2 @@ verbose(...logData) {

* Send a log with a level of "warn".
*
* @public
* @param {...LogData} logData
* The log data.
* @returns {void}
*/

@@ -535,5 +402,2 @@ warn(...logData) {

* Flush any asynchronous logs in the queue when an async transport is used.
*
* @public
* @returns {void}
*/

@@ -568,3 +432,3 @@ flush() {

* The log data.
* @returns {{[key: string]: any}}
* @returns {BaseLogData}
* Returns a single zipped object containing all log data.

@@ -578,18 +442,21 @@ */

return clone(
reversedLogData.reduce((collect, item) => {
if (typeof item === 'string') {
return Object.assign(collect, { message: item });
}
if (item instanceof Error) {
return Object.assign(collect, { error: serializeError(item) });
}
return Object.assign(collect, item);
}, {})
reversedLogData.reduce(
/**
* @param {BaseLogData} collect
* @param {LogData} item
* @returns {BaseLogData}
*/
(collect, item) => {
if (typeof item === 'string') {
return Object.assign(collect, { message: item });
}
if (item instanceof Error) {
return Object.assign(collect, { error: serializeError(item) });
}
return Object.assign(collect, item);
},
{}
)
);
}
}
module.exports = Logger;
// @ts-ignore
module.exports.default = module.exports;
};
/**
* @typedef {object} LegacyMaskTransformOptions
* @property {string[]} [denyList]
* Additional field names to apply masking to.
* @property {string[]} [allowList]
* Field names to allow from the default deny list.
* @property {string} [maskString]
* The mask string to apply to discovered sensitive values.
* @import { InternalMaskSettings } from '../../types/transforms/legacy-mask'
* @import { createLegacyMaskTransform as CreateLegacyMaskTransform } from '../../types/transforms/legacy-mask'
*/
/**
* @typedef {object} InternalMaskSettings
* @property {Set<string>} maskedFields
* Field names to mask.
* @property {RegExp} maskRegExp
* A regular expression which applies masking to a string.
* @property {string} maskString
* The mask string to apply to discovered sensitive values.
* @property {WeakSet} references
* An internal store of references used to avoid masking the same object infinitely.
*/
/**
* The default masked fields.

@@ -163,8 +146,5 @@ *

*
* @param {LegacyMaskTransformOptions} options
* Masking options.
* @returns {import('../logger').LogTransform}
* Returns a transform function for use with the logger.
* @type {CreateLegacyMaskTransform}
*/
function createLegacyMaskTransform({
module.exports = function createLegacyMaskTransform({
denyList = [],

@@ -196,7 +176,2 @@ allowList = [],

};
}
module.exports = createLegacyMaskTransform;
// @ts-ignore
module.exports.default = module.exports;
};
{
"name": "@dotcom-reliability-kit/logger",
"version": "3.1.2",
"version": "3.1.3",
"description": "A simple and fast logger based on Pino, with FT preferences baked in",

@@ -17,3 +17,4 @@ "repository": {

},
"main": "lib",
"main": "lib/index.js",
"types": "types/index.d.ts",
"dependencies": {

@@ -20,0 +21,0 @@ "@dotcom-reliability-kit/app-info": "^3.2.0",

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