@seek/logger
Advanced tools
Comparing version 5.0.2 to 5.1.0
@@ -6,6 +6,8 @@ "use strict"; | ||
const redactedDummy = '[Redacted]'; | ||
const withRedaction = (dest) => { | ||
const withRedaction = (dest, redactText) => { | ||
const write = dest.write.bind(dest); | ||
dest.write = (input) => { | ||
const redacted = input.replace(bearerMatcher, redactedDummy); | ||
var _a; | ||
let redacted = input.replace(bearerMatcher, redactedDummy); | ||
redacted = (_a = redactText === null || redactText === void 0 ? void 0 : redactText(redacted, redactedDummy)) !== null && _a !== void 0 ? _a : redacted; | ||
return write(redacted); | ||
@@ -12,0 +14,0 @@ }; |
@@ -9,3 +9,3 @@ "use strict"; | ||
return { | ||
log: (input) => trim(input), // eslint-disable-line @typescript-eslint/ban-types | ||
log: (input) => trim(input), | ||
}; | ||
@@ -12,0 +12,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -38,11 +42,24 @@ if (k2 === undefined) k2 = k; | ||
*/ | ||
exports.default = (opts = {}, destination = pino_1.default.destination(1)) => { | ||
exports.default = ( | ||
// istanbul ignore next | ||
opts = {}, | ||
// istanbul ignore next | ||
destination = pino_1.default.destination(1)) => { | ||
const formatters = (0, formatters_1.createFormatters)(opts); | ||
opts.redact = redact.addDefaultRedactPathStrings(opts.redact); | ||
opts.serializers = Object.assign(Object.assign({}, serializers_1.default), opts.serializers); | ||
opts.base = Object.assign(Object.assign({}, base_1.default), opts.base); | ||
opts.formatters = Object.assign(Object.assign({}, formatters), opts.formatters); | ||
opts.serializers = { | ||
...serializers_1.default, | ||
...opts.serializers, | ||
}; | ||
opts.base = { | ||
...base_1.default, | ||
...opts.base, | ||
}; | ||
opts.formatters = { | ||
...formatters, | ||
...opts.formatters, | ||
}; | ||
opts.timestamp = () => `,"timestamp":"${new Date().toISOString()}"`; | ||
return (0, pino_1.default)(opts, (0, destination_1.withRedaction)(destination)); | ||
return (0, pino_1.default)(opts, (0, destination_1.withRedaction)(destination, opts.redactText)); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -31,4 +31,7 @@ "use strict"; | ||
: response; | ||
exports.default = Object.assign(Object.assign({}, pino_std_serializers_1.default), { res, | ||
req }); | ||
exports.default = { | ||
...pino_std_serializers_1.default, | ||
res, | ||
req, | ||
}; | ||
//# sourceMappingURL=index.js.map |
const bearerMatcher = /\bbearer\s[\w._-]{25,}/gi; | ||
const redactedDummy = '[Redacted]'; | ||
export const withRedaction = (dest) => { | ||
export const withRedaction = (dest, redactText) => { | ||
const write = dest.write.bind(dest); | ||
dest.write = (input) => { | ||
const redacted = input.replace(bearerMatcher, redactedDummy); | ||
var _a; | ||
let redacted = input.replace(bearerMatcher, redactedDummy); | ||
redacted = (_a = redactText === null || redactText === void 0 ? void 0 : redactText(redacted, redactedDummy)) !== null && _a !== void 0 ? _a : redacted; | ||
return write(redacted); | ||
@@ -8,0 +10,0 @@ }; |
@@ -6,5 +6,5 @@ import { trimmer } from 'dtrim'; | ||
return { | ||
log: (input) => trim(input), // eslint-disable-line @typescript-eslint/ban-types | ||
log: (input) => trim(input), | ||
}; | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -13,11 +13,24 @@ import pino from 'pino'; | ||
*/ | ||
export default (opts = {}, destination = pino.destination(1)) => { | ||
export default ( | ||
// istanbul ignore next | ||
opts = {}, | ||
// istanbul ignore next | ||
destination = pino.destination(1)) => { | ||
const formatters = createFormatters(opts); | ||
opts.redact = redact.addDefaultRedactPathStrings(opts.redact); | ||
opts.serializers = Object.assign(Object.assign({}, serializers), opts.serializers); | ||
opts.base = Object.assign(Object.assign({}, base), opts.base); | ||
opts.formatters = Object.assign(Object.assign({}, formatters), opts.formatters); | ||
opts.serializers = { | ||
...serializers, | ||
...opts.serializers, | ||
}; | ||
opts.base = { | ||
...base, | ||
...opts.base, | ||
}; | ||
opts.formatters = { | ||
...formatters, | ||
...opts.formatters, | ||
}; | ||
opts.timestamp = () => `,"timestamp":"${new Date().toISOString()}"`; | ||
return pino(opts, withRedaction(destination)); | ||
return pino(opts, withRedaction(destination, opts.redactText)); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -26,4 +26,7 @@ import stdSerializers from 'pino-std-serializers'; | ||
: response; | ||
export default Object.assign(Object.assign({}, stdSerializers), { res, | ||
req }); | ||
export default { | ||
...stdSerializers, | ||
res, | ||
req, | ||
}; | ||
//# sourceMappingURL=index.js.map |
import pino from 'pino'; | ||
export declare const withRedaction: (dest: pino.DestinationStream) => pino.DestinationStream; | ||
import { FormatterOptions } from '../formatters'; | ||
export declare const withRedaction: (dest: pino.DestinationStream, redactText: FormatterOptions['redactText']) => pino.DestinationStream; |
@@ -7,3 +7,7 @@ import pino from 'pino'; | ||
maxObjectDepth?: number; | ||
/** | ||
* This allows finer control of redaction by providing access to the full text. | ||
*/ | ||
redactText?: (input: string, redactionPlaceholder: string) => string; | ||
} | ||
export declare const createFormatters: (opts: FormatterOptions) => pino.LoggerOptions['formatters']; |
@@ -1,3 +0,11 @@ | ||
import pino from 'pino'; | ||
export declare const defaultRedact: never[]; | ||
export declare const addDefaultRedactPathStrings: (redact: string[] | pino.redactOptions | undefined) => string[] | pino.redactOptions; | ||
/** | ||
* Private interface vendored from `pino` | ||
*/ | ||
interface redactOptions { | ||
paths: string[]; | ||
censor?: string | ((value: any, path: string[]) => any); | ||
remove?: boolean; | ||
} | ||
export declare const addDefaultRedactPathStrings: (redact: string[] | redactOptions | undefined) => string[] | redactOptions; | ||
export {}; |
@@ -10,3 +10,3 @@ { | ||
"dtrim": "^1.9.0", | ||
"pino": "^7.0.2", | ||
"pino": "^7.10.0", | ||
"pino-std-serializers": "^5.0.0" | ||
@@ -16,9 +16,8 @@ }, | ||
"devDependencies": { | ||
"@types/node": "11.15.54", | ||
"@types/split2": "3.2.1", | ||
"skuba": "4.1.1", | ||
"skuba": "4.2.0", | ||
"split2": "4.1.0" | ||
}, | ||
"engines": { | ||
"node": ">=8", | ||
"node": ">=12", | ||
"npm": ">=5.5.0" | ||
@@ -51,2 +50,3 @@ }, | ||
"test": "skuba test", | ||
"test:ci": "skuba test --coverage", | ||
"prepush": "yarn test", | ||
@@ -63,3 +63,3 @@ "release": "yarn build && skuba release" | ||
"types": "./lib-types/index.d.ts", | ||
"version": "5.0.2" | ||
"version": "5.1.0" | ||
} |
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
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
27341
3
326
Updatedpino@^7.10.0