From acbd48b999a095e088ac5ff3e249b5ca3532c653 Mon Sep 17 00:00:00 2001 From: alexlianides <114772744+alexlianides@users.noreply.github.com> Date: Tue, 23 Jul 2024 17:51:52 -0700 Subject: [PATCH] logging update to include status for responses (#16) Co-authored-by: alianides --- src/HostServices/Link.cs | 4 ++-- src/HostServices/Logging.cs | 8 ++++---- src/HostServices/Position.cs | 4 ++-- src/HostServices/Sensor.cs | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/HostServices/Link.cs b/src/HostServices/Link.cs index e30703a..aeb4137 100644 --- a/src/HostServices/Link.cs +++ b/src/HostServices/Link.cs @@ -106,7 +106,7 @@ private static ILogger Logger { void LinkResponseEventHandler(object? _, MessageFormats.HostServices.Link.LinkResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == linkRequest.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); if (eventHandlerResponse.ResponseHeader.Status != MessageFormats.Common.StatusCodes.Pending) { response = eventHandlerResponse; @@ -137,7 +137,7 @@ void LinkResponseEventHandler(object? _, MessageFormats.HostServices.Link.LinkRe throw new TimeoutException($"Timed out waiting for a response from {TARGET_SERVICE_APP_ID}"); } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(LinkResponse), response.ResponseHeader.Status, linkRequest.RequestHeader.TrackingId, linkRequest.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(LinkResponse), response.ResponseHeader.Status, linkRequest.RequestHeader.TrackingId, linkRequest.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; }); diff --git a/src/HostServices/Logging.cs b/src/HostServices/Logging.cs index 3433ba7..6750de6 100644 --- a/src/HostServices/Logging.cs +++ b/src/HostServices/Logging.cs @@ -56,7 +56,7 @@ private static ILogger Logger { if (waitForResponse == true) { void LogMessageResponseEventHandler(object? _, MessageFormats.Common.LogMessageResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == logMessage.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.LogMessageResponseEvent -= LogMessageResponseEventHandler; // Remove the callback so it's not called for future iterations } @@ -87,7 +87,7 @@ void LogMessageResponseEventHandler(object? _, MessageFormats.Common.LogMessageR } } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(LogMessageResponse), response.ResponseHeader.Status, logMessage.RequestHeader.TrackingId, logMessage.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(LogMessageResponse), response.ResponseHeader.Status, logMessage.RequestHeader.TrackingId, logMessage.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; }); @@ -122,7 +122,7 @@ void LogMessageResponseEventHandler(object? _, MessageFormats.Common.LogMessageR if (waitForResponse == true) { void TelemetryResponseEventHandler(object? _, MessageFormats.Common.TelemetryMetricResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == telemetryMessage.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.TelemetryMetricResponseEvent -= TelemetryResponseEventHandler; // Remove the callback so it's not called for future iterations @@ -153,7 +153,7 @@ void TelemetryResponseEventHandler(object? _, MessageFormats.Common.TelemetryMet } } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(TelemetryMetricResponse), response.ResponseHeader.Status, telemetryMessage.RequestHeader.TrackingId, telemetryMessage.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(TelemetryMetricResponse), response.ResponseHeader.Status, telemetryMessage.RequestHeader.TrackingId, telemetryMessage.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; }); diff --git a/src/HostServices/Position.cs b/src/HostServices/Position.cs index fd6fa86..e732d6f 100644 --- a/src/HostServices/Position.cs +++ b/src/HostServices/Position.cs @@ -48,7 +48,7 @@ private static ILogger Logger { // Create an in-line callback function to get the response for this message void PositionResponseEventHandler(object? _, MessageFormats.HostServices.Position.PositionResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == positionRequest.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.PositionResponseEvent -= PositionResponseEventHandler; // Remove myself for next time @@ -79,7 +79,7 @@ void PositionResponseEventHandler(object? _, MessageFormats.HostServices.Positio throw new TimeoutException($"Timed out waiting for a response from {TARGET_SERVICE_APP_ID}"); } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(PositionResponse), response.ResponseHeader.Status, positionRequest.RequestHeader.TrackingId, positionRequest.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(PositionResponse), response.ResponseHeader.Status, positionRequest.RequestHeader.TrackingId, positionRequest.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; }); diff --git a/src/HostServices/Sensor.cs b/src/HostServices/Sensor.cs index a8efc04..659f6a6 100644 --- a/src/HostServices/Sensor.cs +++ b/src/HostServices/Sensor.cs @@ -50,7 +50,7 @@ private static ILogger Logger { void SensorsAvailableResponseEventHandler(object? _, MessageFormats.HostServices.Sensor.SensorsAvailableResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == sensorsAvailableRequest.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.SensorsAvailableResponseEvent -= SensorsAvailableResponseEventHandler; } @@ -79,7 +79,7 @@ void SensorsAvailableResponseEventHandler(object? _, MessageFormats.HostServices throw new TimeoutException($"Timed out waiting for a response from {TARGET_SERVICE_APP_ID}"); } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(SensorsAvailableResponse), response.ResponseHeader.Status, sensorsAvailableRequest.RequestHeader.TrackingId, sensorsAvailableRequest.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(SensorsAvailableResponse), response.ResponseHeader.Status, sensorsAvailableRequest.RequestHeader.TrackingId, sensorsAvailableRequest.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; }); @@ -126,7 +126,7 @@ void SensorsAvailableResponseEventHandler(object? _, MessageFormats.HostServices void TaskingPreCheckResponseEventHandler(object? _, MessageFormats.HostServices.Sensor.TaskingPreCheckResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == taskingPreCheckRequest.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.SensorsTaskingPreCheckResponseEvent -= TaskingPreCheckResponseEventHandler; @@ -155,7 +155,7 @@ void TaskingPreCheckResponseEventHandler(object? _, MessageFormats.HostServices. throw new TimeoutException($"Timed out waiting for a response from {TARGET_SERVICE_APP_ID}"); } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(TaskingPreCheckResponse), response.ResponseHeader.Status, taskingPreCheckRequest.RequestHeader.TrackingId, taskingPreCheckRequest.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(TaskingPreCheckResponse), response.ResponseHeader.Status, taskingPreCheckRequest.RequestHeader.TrackingId, taskingPreCheckRequest.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response; @@ -201,7 +201,7 @@ void TaskingPreCheckResponseEventHandler(object? _, MessageFormats.HostServices. void TaskingResponseEventHandler(object? _, MessageFormats.HostServices.Sensor.TaskingResponse eventHandlerResponse) { if (eventHandlerResponse.ResponseHeader.TrackingId == taskingRequest.RequestHeader.TrackingId) { - Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId); + Logger.LogDebug("Message response received for '{messageType}'. Status: '{status}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", eventHandlerResponse.GetType().Name, eventHandlerResponse.ResponseHeader.Status, eventHandlerResponse.ResponseHeader.TrackingId, eventHandlerResponse.ResponseHeader.CorrelationId, eventHandlerResponse.ResponseHeader.Status); response = eventHandlerResponse; Client.SensorsTaskingResponseEvent -= TaskingResponseEventHandler; @@ -231,7 +231,7 @@ void TaskingResponseEventHandler(object? _, MessageFormats.HostServices.Sensor.T throw new TimeoutException($"Timed out waiting for a response from {TARGET_SERVICE_APP_ID}"); } - Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}')", nameof(TaskingResponse), response.ResponseHeader.Status, taskingRequest.RequestHeader.TrackingId, taskingRequest.RequestHeader.CorrelationId); + Logger.LogDebug("Returning '{messageType}' with status '{status}' to payload app (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", nameof(TaskingResponse), response.ResponseHeader.Status, taskingRequest.RequestHeader.TrackingId, taskingRequest.RequestHeader.CorrelationId, response.ResponseHeader.Status); return response;