From 0da80cb1270c6b56c6b5c5f140052b62c8045b0b Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 29 Oct 2015 11:16:23 +0100 Subject: [PATCH] Add direction parameter to IS101Logger.LogException This will allow us to log whether the exception originated with the provider or the consumer. References #1 --- Lawo.EmberPlus/S101/IS101Logger.cs | 2 +- Lawo.EmberPlus/S101/S101Client.cs | 2 +- Lawo.EmberPlus/S101/S101Logger.cs | 3 ++- Lawo.EmberPlusTest/S101/S101LoggerTest.cs | 2 +- Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lawo.EmberPlus/S101/IS101Logger.cs b/Lawo.EmberPlus/S101/IS101Logger.cs index f6e2201a..6e432b9e 100644 --- a/Lawo.EmberPlus/S101/IS101Logger.cs +++ b/Lawo.EmberPlus/S101/IS101Logger.cs @@ -53,6 +53,6 @@ public interface IS101Logger : IDisposable /// Logs . /// equals null. /// has been called. - EventInfo LogException(Exception exception); + EventInfo LogException(string direction, Exception exception); } } diff --git a/Lawo.EmberPlus/S101/S101Client.cs b/Lawo.EmberPlus/S101/S101Client.cs index 89ee8243..49aec281 100644 --- a/Lawo.EmberPlus/S101/S101Client.cs +++ b/Lawo.EmberPlus/S101/S101Client.cs @@ -325,7 +325,7 @@ private async void ReadLoop(IDisposable connection, S101Reader reader) } else { - logAction = () => this.logger.LogException(exception); + logAction = () => this.logger.LogException(LogNames.Receive, exception); } // We're deliberately not awaiting this task, so that the Dispose call will be enqueued even if this diff --git a/Lawo.EmberPlus/S101/S101Logger.cs b/Lawo.EmberPlus/S101/S101Logger.cs index 77bf8b3a..cf8d91d8 100644 --- a/Lawo.EmberPlus/S101/S101Logger.cs +++ b/Lawo.EmberPlus/S101/S101Logger.cs @@ -115,7 +115,7 @@ public EventInfo LogMessage(string direction, S101Message message, byte[] payloa } /// - public EventInfo LogException(Exception exception) + public EventInfo LogException(string direction, Exception exception) { if (exception == null) { @@ -123,6 +123,7 @@ public EventInfo LogException(Exception exception) } var info = new EventInfo(this.WriteStartEvent(LogNames.Exception)); + this.xmlLogWriter.WriteAttributeString(LogNames.Direction, direction); this.xmlLogWriter.WriteString(exception.ToString()); this.WriteEndEvent(); return info; diff --git a/Lawo.EmberPlusTest/S101/S101LoggerTest.cs b/Lawo.EmberPlusTest/S101/S101LoggerTest.cs index 46307725..8f372eff 100644 --- a/Lawo.EmberPlusTest/S101/S101LoggerTest.cs +++ b/Lawo.EmberPlusTest/S101/S101LoggerTest.cs @@ -36,7 +36,7 @@ public void MainTest() () => logger.LogData("Whatever", "Send", null, 0, 0), () => logger.LogMessage(null, new S101Message(0x00, new KeepAliveRequest()), null), () => logger.LogMessage("Send", null, null), - () => logger.LogException(null)); + () => logger.LogException("Send", null)); } } } diff --git a/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs b/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs index 0a5c88ab..a3799a71 100644 --- a/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs +++ b/Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs @@ -377,7 +377,7 @@ private async Task ForwardLoop(TcpListener listener) if (exception != null) { await EnqueueLogOperationAsync( - logInfo, "Exception", null, null, i => i.Logger.LogException(exception)); + logInfo, "Exception", null, null, i => i.Logger.LogException(null, exception)); } await EnqueueLogOperationAsync(logInfo, null, null, null, i => { i.Dispose(); return new EventInfo(); });