-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
Redaction is gated on redactionConfig?.enabled, so even if the user calls configureRedaction() with patterns, logs won't be redacted unless they also pass redaction: { enabled: true } to createLogger.
Current behavior:
// Configure global redaction patterns
configureRedaction({
keys: ["apiKey", "password"],
patterns: [/sk-[a-zA-Z0-9]+/g],
});
// This logger will NOT redact because enabled defaults to false
const logger = createLogger({ name: "my-app" });
logger.info("Request", { apiKey: "secret" }); // "secret" is NOT redactedExpected behavior:
// Same setup as above...
const logger = createLogger({ name: "my-app" });
logger.info("Request", { apiKey: "secret" }); // "secret" IS redacted (because global rules exist)Proposed Solution
In createLogger(), check if global redaction rules exist before skipping redaction:
const hasGlobalRules =
(globalRedactionConfig.patterns?.length ?? 0) > 0 ||
(globalRedactionConfig.keys?.length ?? 0) > 0;
if ((redactionConfig && redactionConfig.enabled !== false) || hasGlobalRules) {
// Apply redaction...
}Location
packages/logging/src/index.ts around line 522-523
Origin
PR review feedback @b4d5b on #31
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
No labels