Skip to content

Commit 3dc5d58

Browse files
authored
Merge pull request #1108 from quickfix-j/copilot/replace-logerror-with-session-log
Replace `logError()` with `Session.getLog()` in `SessionConnector`
2 parents 031152a + 9e29ecf commit 3dc5d58

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

quickfixj-core/src/main/java/quickfix/mina/SessionConnector.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import quickfix.Connector;
2828
import quickfix.ExecutorFactory;
2929
import quickfix.FieldConvertError;
30+
import quickfix.LogUtil;
3031
import quickfix.Session;
3132
import quickfix.SessionFactory;
3233
import quickfix.SessionID;
@@ -243,7 +244,7 @@ protected void logoutAllSessions(boolean forceDisconnect) {
243244
try {
244245
session.logout();
245246
} catch (Throwable e) {
246-
logError(session.getSessionID(), null, "Error during logout", e);
247+
LogUtil.logThrowable(session.getLog(), "Error during logout", e);
247248
}
248249
}
249250

@@ -255,7 +256,7 @@ protected void logoutAllSessions(boolean forceDisconnect) {
255256
session.disconnect("Forcibly disconnecting session", false);
256257
}
257258
} catch (Throwable e) {
258-
logError(session.getSessionID(), null, "Error during disconnect", e);
259+
LogUtil.logThrowable(session.getLog(), "Error during disconnect", e);
259260
}
260261
}
261262
} else {
@@ -295,21 +296,6 @@ protected void waitForLogout() {
295296
}
296297
}
297298

298-
protected void logError(SessionID sessionID, IoSession protocolSession, String message, Throwable t) {
299-
log.error(message + getLogSuffix(sessionID, protocolSession), t);
300-
}
301-
302-
private String getLogSuffix(SessionID sessionID, IoSession protocolSession) {
303-
String suffix = ":";
304-
if (sessionID != null) {
305-
suffix += "sessionID=" + sessionID.toString() + ";";
306-
}
307-
if (protocolSession != null) {
308-
suffix += "address=" + protocolSession.getRemoteAddress();
309-
}
310-
return suffix;
311-
}
312-
313299
protected void startSessionTimer() {
314300
// Check if a session timer is already running to avoid creating multiple timers
315301
if (checkSessionTimerRunning()) {
@@ -351,7 +337,7 @@ public void run() {
351337
try {
352338
session.next();
353339
} catch (IOException e) {
354-
logError(session.getSessionID(), null, "Error in session timer processing", e);
340+
LogUtil.logThrowable(session.getLog(), "Error in session timer processing", e);
355341
}
356342
}
357343
} catch (Throwable e) {

0 commit comments

Comments
 (0)