-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
allow setting a custom Redacted.toString #3966
base: next-minor
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 76fca8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 34 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A better approach might be to use a |
0917fd2
to
4f461b2
Compare
I started working on this idea yesterday) I agree that it is convenient. proto = {
...
label: "redacted",
toString() {
return `<${this.label}>`
},
toJSON() {
return `<${this.label}>`
},
[NodeInspectSymbol]() {
return `<${this.label}>`
},
...
}
export const make = <T>(
value: T,
options?: {
label?: string | undefined
} | undefined
): Redacted.Redacted<T> => {
const redacted = Object.create(proto)
if (options?.label !== undefined) {
redacted.label = options?.label
}
redactedRegistry.set(redacted, value)
return redacted
} Could you please integrate this idea into this places as well?
|
f45ce22
to
1e52c1b
Compare
I think having a custom string is much better than forcing the "<>" wrapper. I was looking at the Config.redacted implementation as well and I think it makes more sense to use a |
1a4cddc
to
693a803
Compare
f242776
to
e600b0a
Compare
e600b0a
to
8250215
Compare
23d5577
to
c992640
Compare
Allow setting a custom string when creating redacted values e.g. "REDACTED_TOKEN" which is logged as:
level=INFO msg="permission granted" user=Perry token=REDACTED_TOKEN
This is useful for keeping tract of redacted values between log statements and is a feature provided by a few other logging libraries.