Fix jwt-token

This commit is contained in:
2025-09-23 15:56:52 +02:00
parent 4747900c7b
commit 25d910ed3f
3 changed files with 47 additions and 17 deletions

View File

@@ -10,6 +10,7 @@ class DataRetentionAuditLogger {
constructor() {
this.logDir = process.env.SECURITY_LOG_DIR || './logs';
this.logFile = path.join(this.logDir, 'data_retention_access.log');
this.loggedWriteError = false; // Flag to avoid spamming write error messages
}
async ensureLogDir() {
@@ -49,11 +50,23 @@ class DataRetentionAuditLogger {
} catch (writeError) {
// Fallback to console logging if file writing fails (e.g., permission issues)
console.log('[DATA_RETENTION_AUDIT]', JSON.stringify(logEntry));
// Only log the file write error once to avoid spam
if (!this.loggedWriteError) {
console.warn('Failed to write security log to file, using console logging:', writeError.message);
this.loggedWriteError = true;
}
}
} catch (error) {
// Fallback to console logging for any errors
console.log('[DATA_RETENTION_AUDIT_ERROR]', error.message, JSON.stringify(event, null, 2));
console.log('[DATA_RETENTION_AUDIT_ERROR]', error.message);
console.log('[DATA_RETENTION_AUDIT_FALLBACK]', JSON.stringify({
timestamp: new Date().toISOString(),
event: event.type || 'UNKNOWN',
result: event.result || 'error',
error: event.error || error.message
}));
}
}