Skip to content

Commit

Permalink
Add direction parameter to IS101Logger.LogException
Browse files Browse the repository at this point in the history
This will allow us to log whether the exception originated with the provider or the consumer.

References #1
  • Loading branch information
andreashuber-lawo committed Oct 29, 2015
1 parent 2e4162e commit 0da80cb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Lawo.EmberPlus/S101/IS101Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public interface IS101Logger : IDisposable
/// <summary>Logs <paramref name="exception"/>.</summary>
/// <exception cref="ArgumentNullException"><paramref name="exception"/> equals <c>null</c>.</exception>
/// <exception cref="ObjectDisposedException"><see cref="IDisposable.Dispose"/> has been called.</exception>
EventInfo LogException(Exception exception);
EventInfo LogException(string direction, Exception exception);
}
}
2 changes: 1 addition & 1 deletion Lawo.EmberPlus/S101/S101Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Lawo.EmberPlus/S101/S101Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ public EventInfo LogMessage(string direction, S101Message message, byte[] payloa
}

/// <inheritdoc/>
public EventInfo LogException(Exception exception)
public EventInfo LogException(string direction, Exception exception)
{
if (exception == null)
{
throw new ArgumentNullException("exception");
}

var info = new EventInfo(this.WriteStartEvent(LogNames.Exception));
this.xmlLogWriter.WriteAttributeString(LogNames.Direction, direction);
this.xmlLogWriter.WriteString(exception.ToString());
this.WriteEndEvent();
return info;
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusTest/S101/S101LoggerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(); });
Expand Down

0 comments on commit 0da80cb

Please sign in to comment.