Skip to content

Commit 19be06d

Browse files
author
PCOffline
committed
feat: dont log sensitive info by default in debug
1 parent a37dc52 commit 19be06d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default {
2525
preferPath: true, // When both path and data are provided, ignore the data and only use the path. If false, only the data will be used in such case.
2626
logLevel: 'info', // 'debug' | 'info' | 'warn' | 'error' | 'silent'
2727
mongoUri: 'mongodb://localhost:27017/my-database', // Can also be retrieved from environment variable: MONGO_URI, MONGODB_URI, DB_URI, DATABASE_URI or mongoUri
28+
sensitiveDebugLog: false, // Log information that is considered sensitive (such as the MongoDB URI) in debug mode.
2829
collections: {
2930
collectionName: {
3031
schema: new Schema({

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ const standardCollections = [];
9292

9393
function logDebugData() {
9494
if (logLevel > logLevels.debug) return;
95+
const { dbUri, ...printableConfig } = config;
9596

9697
logDebug(`[${logDebugData.name}]`, 'Log Level:', logLevel);
97-
logDebug(`[${logDebugData.name}]`, 'Config:', JSON.stringify(config));
98+
logDebug(`[${logDebugData.name}]`, 'Config:', JSON.stringify(config.insecureDebugLog ? printableConfig : config));
9899
logDebug(`[${logDebugData.name}]`, 'Standard Collections:', JSON.stringify(standardCollections));
99100
}
100101

0 commit comments

Comments
 (0)