= ['mail', 'email', 'password', 'name', 'token']; // 危険なkey const logObject = {...data}; sensitiveFields.forEach(field => { if (logObject[field]) logObject[field] = '***REDACTED***'; }); console.log(JSON.stringify(logObject)); } redactLog({ name: "John", password: "foo123", id: "1", status: 200, timestamp: "2025/05/21T10:00:00.123Z", }) // { // "name": "***REDACTED***", // "password": "***REDACTED***", // "id": "1", // "status": 200, // "timestamp": "2025/05/21T10:00:00.123Z" // }