@seek/logger
Advanced tools
Comparing version 8.1.1 to 9.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFormatters = void 0; | ||
exports.createFormatters = exports.DEFAULT_MAX_OBJECT_DEPTH = void 0; | ||
const dtrim_1 = require("dtrim"); | ||
exports.DEFAULT_MAX_OBJECT_DEPTH = 4; | ||
const createFormatters = (opts) => { | ||
const trim = (0, dtrim_1.trimmer)({ | ||
depth: opts.maxObjectDepth ?? 4, | ||
depth: opts.maxObjectDepth ?? exports.DEFAULT_MAX_OBJECT_DEPTH, | ||
retain: new Set(Object.keys(opts.serializers)), | ||
@@ -9,0 +10,0 @@ }); |
@@ -50,6 +50,3 @@ "use strict"; | ||
opts.redact = redact.addDefaultRedactPathStrings(opts.redact); | ||
const serializers = { | ||
...(0, serializers_1.createSerializers)(opts), | ||
...opts.serializers, | ||
}; | ||
const serializers = (0, serializers_1.createSerializers)(opts); | ||
opts.serializers = serializers; | ||
@@ -56,0 +53,0 @@ const formatters = (0, formatters_1.createFormatters)({ ...opts, serializers }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createSerializers = exports.DEFAULT_OMIT_HEADER_NAMES = void 0; | ||
exports.createSerializers = exports.trimSerializerOutput = exports.DEFAULT_OMIT_HEADER_NAMES = void 0; | ||
const dtrim_1 = require("dtrim"); | ||
const pino_std_serializers_1 = require("pino-std-serializers"); | ||
const formatters_1 = require("../formatters"); | ||
const omitPropertiesSerializer_1 = require("./omitPropertiesSerializer"); | ||
@@ -37,10 +39,23 @@ exports.DEFAULT_OMIT_HEADER_NAMES = Object.freeze([ | ||
: response; | ||
const trimSerializerOutput = (serializer, trim) => (input) => trim(serializer(input)); | ||
exports.trimSerializerOutput = trimSerializerOutput; | ||
const createSerializers = (opts) => { | ||
const serializeHeaders = (0, omitPropertiesSerializer_1.createOmitPropertiesSerializer)(opts.omitHeaderNames ?? exports.DEFAULT_OMIT_HEADER_NAMES); | ||
const serializers = { | ||
// We are trimming inside one level of property nesting. | ||
const depth = Math.max(0, (opts.maxObjectDepth ?? formatters_1.DEFAULT_MAX_OBJECT_DEPTH) - 1); | ||
const errSerializers = trimSerializers({ | ||
err: pino_std_serializers_1.err, | ||
errWithCause: pino_std_serializers_1.errWithCause, | ||
}, | ||
// Retain long stack traces for troubleshooting purposes. | ||
(0, dtrim_1.trimmer)({ depth, retain: new Set(['stack']) })); | ||
const restSerializers = trimSerializers({ | ||
req: createReqSerializer(serializeHeaders), | ||
res, | ||
headers: serializeHeaders, | ||
...opts.serializers, | ||
}, (0, dtrim_1.trimmer)({ depth })); | ||
const serializers = { | ||
...errSerializers, | ||
...restSerializers, | ||
}; | ||
@@ -50,2 +65,3 @@ return serializers; | ||
exports.createSerializers = createSerializers; | ||
const trimSerializers = (serializers, trim) => Object.fromEntries(Object.entries(serializers).map(([property, serializer]) => [property, (0, exports.trimSerializerOutput)(serializer, trim)])); | ||
//# sourceMappingURL=index.js.map |
import { trimmer } from 'dtrim'; | ||
export const DEFAULT_MAX_OBJECT_DEPTH = 4; | ||
export const createFormatters = (opts) => { | ||
const trim = trimmer({ | ||
depth: opts.maxObjectDepth ?? 4, | ||
depth: opts.maxObjectDepth ?? DEFAULT_MAX_OBJECT_DEPTH, | ||
retain: new Set(Object.keys(opts.serializers)), | ||
@@ -6,0 +7,0 @@ }); |
@@ -19,6 +19,3 @@ import pino from 'pino'; | ||
opts.redact = redact.addDefaultRedactPathStrings(opts.redact); | ||
const serializers = { | ||
...createSerializers(opts), | ||
...opts.serializers, | ||
}; | ||
const serializers = createSerializers(opts); | ||
opts.serializers = serializers; | ||
@@ -25,0 +22,0 @@ const formatters = createFormatters({ ...opts, serializers }); |
@@ -0,2 +1,4 @@ | ||
import { trimmer } from 'dtrim'; | ||
import { err, errWithCause } from 'pino-std-serializers'; | ||
import { DEFAULT_MAX_OBJECT_DEPTH } from '../formatters'; | ||
import { createOmitPropertiesSerializer } from './omitPropertiesSerializer'; | ||
@@ -34,13 +36,26 @@ export const DEFAULT_OMIT_HEADER_NAMES = Object.freeze([ | ||
: response; | ||
export const trimSerializerOutput = (serializer, trim) => (input) => trim(serializer(input)); | ||
export const createSerializers = (opts) => { | ||
const serializeHeaders = createOmitPropertiesSerializer(opts.omitHeaderNames ?? DEFAULT_OMIT_HEADER_NAMES); | ||
const serializers = { | ||
// We are trimming inside one level of property nesting. | ||
const depth = Math.max(0, (opts.maxObjectDepth ?? DEFAULT_MAX_OBJECT_DEPTH) - 1); | ||
const errSerializers = trimSerializers({ | ||
err, | ||
errWithCause, | ||
}, | ||
// Retain long stack traces for troubleshooting purposes. | ||
trimmer({ depth, retain: new Set(['stack']) })); | ||
const restSerializers = trimSerializers({ | ||
req: createReqSerializer(serializeHeaders), | ||
res, | ||
headers: serializeHeaders, | ||
...opts.serializers, | ||
}, trimmer({ depth })); | ||
const serializers = { | ||
...errSerializers, | ||
...restSerializers, | ||
}; | ||
return serializers; | ||
}; | ||
const trimSerializers = (serializers, trim) => Object.fromEntries(Object.entries(serializers).map(([property, serializer]) => [property, trimSerializerOutput(serializer, trim)])); | ||
//# sourceMappingURL=index.js.map |
import type { LoggerOptions } from 'pino'; | ||
export declare const DEFAULT_MAX_OBJECT_DEPTH = 4; | ||
export interface FormatterOptions { | ||
@@ -3,0 +4,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { err, errWithCause } from 'pino-std-serializers'; | ||
import type { SerializerFn } from './types'; | ||
import type { pino } from 'pino'; | ||
import type { SerializerFn, TrimmerFn } from './types'; | ||
export declare const DEFAULT_OMIT_HEADER_NAMES: readonly string[]; | ||
@@ -18,30 +18,12 @@ export interface SerializerOptions { | ||
omitHeaderNames?: readonly string[]; | ||
maxObjectDepth?: number; | ||
serializers?: pino.LoggerOptions['serializers']; | ||
} | ||
interface Socket { | ||
remoteAddress?: string; | ||
remotePort?: string; | ||
} | ||
interface Request extends Record<string, unknown> { | ||
method: string; | ||
url: string; | ||
headers: Record<string, string>; | ||
socket?: Socket; | ||
} | ||
interface Response extends Record<string, unknown> { | ||
statusCode?: number; | ||
status?: number; | ||
} | ||
export declare const trimSerializerOutput: (serializer: SerializerFn, trim: TrimmerFn) => SerializerFn; | ||
export declare const createSerializers: (opts: SerializerOptions) => { | ||
err: typeof err; | ||
errWithCause: typeof errWithCause; | ||
req: (request: Request) => Request | { | ||
method: string; | ||
url: string; | ||
headers: unknown; | ||
remoteAddress: string | undefined; | ||
remotePort: string | undefined; | ||
}; | ||
res: (response: Response) => Response; | ||
headers: SerializerFn; | ||
req: SerializerFn; | ||
res: SerializerFn; | ||
err: SerializerFn; | ||
errWithCause: SerializerFn; | ||
}; | ||
export {}; |
@@ -1,1 +0,2 @@ | ||
export type SerializerFn = (input: unknown) => unknown; | ||
export type TrimmerFn = (input: unknown) => unknown; | ||
export type SerializerFn = (input: any) => unknown; |
{ | ||
"name": "@seek/logger", | ||
"version": "8.1.1", | ||
"version": "9.0.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Standardized logging", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
59028
823