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
5
Versions
53
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

to
2.4.0

4

lib/index.d.ts

@@ -8,6 +8,2 @@ export = defaultLogger;

};
type Transforms = {
legacyMask: typeof legacyMask;
};
import legacyMask = require("./transforms/legacy-mask");
//# sourceMappingURL=index.d.ts.map

28

lib/logger.d.ts

@@ -26,15 +26,10 @@ export = Logger;

declare namespace Logger {
export { exports as default, LogLevel, LogData, LoggerOptions, PrivateLoggerOptions, LogTransform, LogTransport, LogLevelInfo };
export { exports as default, LogLevel, LogData, TimeFn, LoggerOptions, PrivateLoggerOptions, LogTransform, LogTransport, LogLevelInfo };
}
declare namespace exports {
export { exports as default, LogLevel, LogData, TimeFn, LoggerOptions, PrivateLoggerOptions, LogTransform, LogTransport, LogLevelInfo };
}
type LogLevel = "silly" | "data" | "debug" | "verbose" | "info" | "warn" | "error" | "fatal";
type LogTransport = {
level?: string | undefined;
debug: (...args: any) => any;
error: (...args: any) => any;
fatal: (...args: any) => any;
info: (...args: any) => any;
warn: (...args: any) => any;
flush?: (() => void) | undefined;
};
type LogData = string | object | Error;
type TimeFn = typeof import('pino').stdTimeFunctions.isoTime;
type LoggerOptions = {

@@ -46,2 +41,3 @@ baseLogData?: LogData;

withTimestamps?: boolean | undefined;
useIsoTimeFormat?: boolean | undefined;
};

@@ -51,5 +47,2 @@ type PrivateLoggerOptions = {

};
declare namespace exports {
export { exports as default, LogLevel, LogData, LoggerOptions, PrivateLoggerOptions, LogTransform, LogTransport, LogLevelInfo };
}
type LogTransform = (logData: {

@@ -60,2 +53,11 @@ [key: string]: any;

};
type LogTransport = {
level?: string | undefined;
debug: (...args: any) => any;
error: (...args: any) => any;
fatal: (...args: any) => any;
info: (...args: any) => any;
warn: (...args: any) => any;
flush?: (() => void) | undefined;
};
type LogLevelInfo = {

@@ -62,0 +64,0 @@ logLevel: LogLevel;

@@ -15,2 +15,6 @@ const pino = require('pino').default;

/**
* @typedef {typeof import('pino').stdTimeFunctions.isoTime} TimeFn
*/
/**
* @typedef {object} LoggerOptions

@@ -28,2 +32,4 @@ * @property {LogData} [baseLogData = {}]

* Whether to send the timestamp that each log method was called.
* @property {boolean} [useIsoTimeFormat = false]
* Whether to format the timestamps as ISO8601.
*/

@@ -196,4 +202,9 @@

// Default and set the timestamps option.
const withTimestamps = options.withTimestamps !== false;
/** @type {boolean | TimeFn} */
let withTimestamps = options.withTimestamps !== false;
if (options.useIsoTimeFormat) {
withTimestamps = pino.stdTimeFunctions.isoTime;
}
if (options._transport) {

@@ -200,0 +211,0 @@ // If we have a configured transport, use it. This means

{
"name": "@dotcom-reliability-kit/logger",
"version": "2.3.1",
"version": "2.4.0",
"description": "A simple and fast logger based on Pino, with FT preferences baked in",

@@ -37,4 +37,4 @@ "repository": {

"@types/lodash.clonedeep": "^4.5.9",
"@types/ungap__structured-clone": "^0.3.2"
"@types/ungap__structured-clone": "^0.3.3"
}
}

@@ -15,2 +15,3 @@

* [`options.withTimestamps`](#optionswithtimestamps)
* [`options.useIsoTimeFormat`](#optionsuseisotimeformat)
* [`logger.log()` and shortcut methods](#loggerlog-and-shortcut-methods)

@@ -223,2 +224,22 @@ * [`logger.flush()`](#loggerflush)

#### `options.useIsoTimeFormat`
Whether to format the `time` property as an [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) standard datetime format. This overrides the `withTimestamps` option.
Must be a `Boolean` and defaults to `false` for backwards-compatibility with previous timestamps, which were formatted as [Unix time](https://en.wikipedia.org/wiki/Unix_time) seconds.
```js
const logger = new Logger({
useIsoTimeFormat: true
});
logger.info('This is a log');
// Outputs:
// {
// "level": "info",
// "message": "This is a log",
// "time": "2020-01-01T12:00:00.000Z"
// }
```
### `logger.log()` and shortcut methods

@@ -225,0 +246,0 @@

Sorry, the diff of this file is not supported yet