-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(serializers): avoid implicit sanitization #2081
base: main
Are you sure you want to change the base?
Changes from all commits
1460394
d84609d
b8b2b74
39b0697
7d47964
b393732
ebd84c3
da9a16f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
'use strict' | ||
|
||
const warning = require('process-warning')() | ||
module.exports = warning | ||
const warning = require('process-warning') | ||
|
||
// const warnName = 'PinoWarning' | ||
/** | ||
* Future flags, specific to the current major-version of Pino. These flags allow for breaking-changes to be introduced | ||
* on a opt-in basis, anticipating behavior of the next major-version. All future flag must be frozen as false. These | ||
* future flags are specific to Pino major-version 9. | ||
*/ | ||
const future = Object.freeze({ | ||
skipUnconditionalStdSerializers: false // see PINODEP010 | ||
}) | ||
|
||
// warning.create(warnName, 'PINODEP010', 'A new deprecation') | ||
const PINODEP010 = warning.createDeprecation({ code: 'PINODEP010', message: 'Unconditional execution of standard serializers for HTTP Request and Response will be discontinued in the next major version.' }) | ||
|
||
module.exports = { | ||
warning: { | ||
PINODEP010 | ||
}, | ||
future | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ type TimeFn = () => string; | |
type MixinFn<CustomLevels extends string = never> = (mergeObject: object, level: number, logger:pino.Logger<CustomLevels>) => object; | ||
type MixinMergeStrategyFn = (mergeObject: object, mixinObject: object) => object; | ||
|
||
type CustomLevelLogger<CustomLevels extends string, UseOnlyCustomLevels extends boolean = boolean> = { | ||
type CustomLevelLogger<CustomLevels extends string, UseOnlyCustomLevels extends boolean = boolean> = { | ||
/** | ||
* Define additional logging levels. | ||
*/ | ||
|
@@ -327,6 +327,9 @@ declare namespace pino { | |
(msg: string, ...args: any[]): void; | ||
} | ||
|
||
/** Future flags for Pino major-version 9. */ | ||
type FutureFlags = 'skipUnconditionalStdSerializers' | ||
|
||
interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> { | ||
transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions | ||
/** | ||
|
@@ -416,6 +419,14 @@ declare namespace pino { | |
* The string key for the 'error' in the JSON object. Default: "err". | ||
*/ | ||
errorKey?: string; | ||
/** | ||
* The string key for the 'Request' in the JSON object. Default: "req". | ||
*/ | ||
requestKey?: string; | ||
/** | ||
* The string key for the 'Response' in the JSON object. Default: "res". | ||
*/ | ||
responseKey?: string; | ||
Comment on lines
+422
to
+429
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The key for request and response are now explicitly configurable. Previously, these had fixed values, set on pino-std-serializers (mapHttpRequest and mapHttpResponse). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this change makes the exported functions |
||
/** | ||
* The string key to place any logged object under. | ||
*/ | ||
|
@@ -662,6 +673,18 @@ declare namespace pino { | |
* logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`. | ||
*/ | ||
crlf?: boolean; | ||
|
||
/** | ||
* The `future` object contains _opt-in_ flags specific to a Pino major version. These flags are used to change behavior, | ||
* anticipating breaking-changes that will be introduced in the next major version. | ||
* @example | ||
* const parent = require('pino')({ | ||
* future: { | ||
* skipUnconditionalStdSerializers: true | ||
* } | ||
* }) | ||
*/ | ||
future?: Partial<Record<FutureFlags, boolean>> | ||
} | ||
|
||
interface ChildLoggerOptions<CustomLevels extends string = never> { | ||
|
@@ -749,12 +772,15 @@ declare namespace pino { | |
readonly formatOptsSym: unique symbol; | ||
readonly messageKeySym: unique symbol; | ||
readonly errorKeySym: unique symbol; | ||
readonly responseKeySym: unique symbol; | ||
readonly requestKeySym: unique symbol; | ||
readonly nestedKeySym: unique symbol; | ||
readonly wildcardFirstSym: unique symbol; | ||
readonly needsMetadataGsym: unique symbol; | ||
readonly useOnlyCustomLevelsSym: unique symbol; | ||
readonly formattersSym: unique symbol; | ||
readonly hooksSym: unique symbol; | ||
readonly futureSym: unique symbol; | ||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed
Object.freeze
is not used for default configuration. This can be easily refactored, if avoiding this feature is intentional.