mirror of
https://github.com/boldsuck/haveno.git
synced 2025-01-05 15:49:23 +00:00
log connection read timeouts at info level
This commit is contained in:
parent
6a798312fe
commit
2dc7405f82
1 changed files with 17 additions and 3 deletions
|
@ -178,6 +178,8 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
private static int numThrottledInvalidRequestReports = 0;
|
||||
private static long lastLoggedWarningTs = 0;
|
||||
private static int numThrottledWarnings = 0;
|
||||
private static long lastLoggedInfoTs = 0;
|
||||
private static int numThrottledInfos = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
|
@ -676,7 +678,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
throttleWarn("SocketException (expected if connection lost). closeConnectionReason=" + closeConnectionReason + "; connection=" + this);
|
||||
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
|
||||
closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT;
|
||||
throttleWarn("Shut down caused by exception " + e.getMessage() + " on connection=" + this);
|
||||
throttleInfo("Shut down caused by exception " + e.getMessage() + " on connection=" + this);
|
||||
} else if (e instanceof EOFException) {
|
||||
closeConnectionReason = CloseConnectionReason.TERMINATED;
|
||||
throttleWarn("Shut down caused by exception " + e.getMessage() + " on connection=" + this);
|
||||
|
@ -937,8 +939,8 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
}
|
||||
|
||||
private synchronized void throttleWarn(String msg) {
|
||||
boolean logWarning = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS;
|
||||
if (logWarning) {
|
||||
boolean doLog = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS;
|
||||
if (doLog) {
|
||||
log.warn(msg);
|
||||
if (numThrottledWarnings > 0) log.warn("{} warnings were throttled since the last log entry", numThrottledWarnings);
|
||||
numThrottledWarnings = 0;
|
||||
|
@ -947,4 +949,16 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
numThrottledWarnings++;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void throttleInfo(String msg) {
|
||||
boolean doLog = System.currentTimeMillis() - lastLoggedInfoTs > LOG_THROTTLE_INTERVAL_MS;
|
||||
if (doLog) {
|
||||
log.info(msg);
|
||||
if (numThrottledInfos > 0) log.info("{} info logs were throttled since the last log entry", numThrottledInfos);
|
||||
numThrottledInfos = 0;
|
||||
lastLoggedInfoTs = System.currentTimeMillis();
|
||||
} else {
|
||||
numThrottledInfos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue