From c283332ef7dac91bf2df800dfc59edea6db28416 Mon Sep 17 00:00:00 2001 From: James Coverdale Date: Thu, 9 Sep 2021 16:01:54 +0100 Subject: [PATCH] Added DEBUG_FILE_LOG_PATH config flag - when set uses a null logger for the client handler thread logging --- QuickFIXn/ClientHandlerThread.cs | 26 +++++++++++++++++--------- QuickFIXn/SessionSettings.cs | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/QuickFIXn/ClientHandlerThread.cs b/QuickFIXn/ClientHandlerThread.cs index 3ece55e4a..4949e421b 100755 --- a/QuickFIXn/ClientHandlerThread.cs +++ b/QuickFIXn/ClientHandlerThread.cs @@ -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) @@ -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); diff --git a/QuickFIXn/SessionSettings.cs b/QuickFIXn/SessionSettings.cs index 7f87d8364..a74515083 100755 --- a/QuickFIXn/SessionSettings.cs +++ b/QuickFIXn/SessionSettings.cs @@ -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";