improve logging
This commit is contained in:
@ -401,23 +401,34 @@ export class ConnectionManager extends LifecycleComponent {
|
||||
// Remove the record from the tracking map
|
||||
this.connectionRecords.delete(record.id);
|
||||
|
||||
// Log connection details
|
||||
// Use deduplicated logging for connection termination
|
||||
if (this.smartProxy.settings.enableDetailedLogging) {
|
||||
logger.log('info',
|
||||
`Connection terminated: ${record.remoteIP}:${record.localPort} (${reason}) - ` +
|
||||
`${plugins.prettyMs(duration)}, IN: ${record.bytesReceived}B, OUT: ${record.bytesSent}B`,
|
||||
logData
|
||||
// For detailed logging, include more info but still deduplicate by IP+reason
|
||||
connectionLogDeduplicator.log(
|
||||
'connection-terminated',
|
||||
'info',
|
||||
`Connection terminated: ${record.remoteIP}:${record.localPort}`,
|
||||
{
|
||||
...logData,
|
||||
duration_ms: duration,
|
||||
bytesIn: record.bytesReceived,
|
||||
bytesOut: record.bytesSent
|
||||
},
|
||||
`${record.remoteIP}-${reason}`
|
||||
);
|
||||
} else {
|
||||
logger.log('info',
|
||||
`Connection terminated: ${record.remoteIP} (${reason}). Active: ${this.connectionRecords.size}`,
|
||||
// For normal logging, deduplicate by termination reason
|
||||
connectionLogDeduplicator.log(
|
||||
'connection-terminated',
|
||||
'info',
|
||||
`Connection terminated`,
|
||||
{
|
||||
connectionId: record.id,
|
||||
remoteIP: record.remoteIP,
|
||||
reason,
|
||||
activeConnections: this.connectionRecords.size,
|
||||
component: 'connection-manager'
|
||||
}
|
||||
},
|
||||
reason // Group by termination reason
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user