Skip to content

Commit

Permalink
Added DEBUG_FILE_LOG_PATH config flag - when set uses a null logger f…
Browse files Browse the repository at this point in the history
…or the client handler thread logging
  • Loading branch information
jamescoverdale authored and James Coverdale committed Sep 9, 2021
1 parent 63f7e97 commit c283332
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
26 changes: 17 additions & 9 deletions QuickFIXn/ClientHandlerThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ExitedEventArgs(ClientHandlerThread clientHandlerThread)
private Thread thread_ = null;
private volatile bool isShutdownRequested_ = false;
private SocketReader socketReader_;
private FileLog log_;
private ILog log_;

[Obsolete("Don't use this constructor")]
public ClientHandlerThread(TcpClient tcpClient, long clientId)
Expand Down Expand Up @@ -62,15 +62,23 @@ public ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictiona
internal ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictionary settingsDict,
SocketSettings socketSettings, AcceptorSocketDescriptor acceptorDescriptor)
{
string debugLogFilePath = "log";
if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH))
debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH);
else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH))
debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH);

// FIXME - do something more flexible than hardcoding a filelog
log_ = new FileLog(debugLogFilePath, new SessionID(
if (settingsDict.Has(SessionSettings.DISABLE_CLIENT_HANDLER_THREAD_LOGS)
&& settingsDict.GetBool(SessionSettings.DISABLE_CLIENT_HANDLER_THREAD_LOGS))
{
log_ = new NullLog();
}
else
{
string debugLogFilePath = "log";
if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH))
debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH);
else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH))
debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH);

// FIXME - do something more flexible than hardcoding a filelog
log_ = new FileLog(debugLogFilePath, new SessionID(
"ClientHandlerThread", clientId.ToString(), "Debug-" + Guid.NewGuid().ToString()));
}

this.Id = clientId;
socketReader_ = new SocketReader(tcpClient, socketSettings, this, acceptorDescriptor);
Expand Down
1 change: 1 addition & 0 deletions QuickFIXn/SessionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class SessionSettings
public const string RECONNECT_INTERVAL = "ReconnectInterval";
public const string FILE_LOG_PATH = "FileLogPath";
public const string DEBUG_FILE_LOG_PATH = "DebugFileLogPath";
public const string DISABLE_CLIENT_HANDLER_THREAD_LOGS = "DisableClientHandlerThreadLogs";
public const string FILE_STORE_PATH = "FileStorePath";
public const string REFRESH_ON_LOGON = "RefreshOnLogon";
public const string RESET_ON_LOGON = "ResetOnLogon";
Expand Down

0 comments on commit c283332

Please sign in to comment.