Skip to content

Commit

Permalink
Merge pull request #15 from microsoft/al/logging
Browse files Browse the repository at this point in the history
add status to response logging
  • Loading branch information
bradarm authored Jul 23, 2024
2 parents 8293498 + a75925c commit 5d82483
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/MessageHandlers/LinkRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void LinkRequestHandler(MessageFormats.HostServices.Link.LinkRequest? me
_fileMoverService.QueueFileMove(returnResponse);


_logger.LogDebug("Sending response type '{messageType}' to '{appId}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", returnResponse.GetType().Name, fullMessage.SourceAppId, returnResponse.ResponseHeader.TrackingId, returnResponse.ResponseHeader.CorrelationId);
_logger.LogDebug("Sending response type '{messageType}' to '{appId}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", returnResponse.GetType().Name, fullMessage.SourceAppId, returnResponse.ResponseHeader.TrackingId, returnResponse.ResponseHeader.CorrelationId, returnResponse.ResponseHeader.Status);

// Route the response back to the calling user
_client.DirectToApp(appId: fullMessage.SourceAppId, message: returnResponse);
Expand Down
12 changes: 6 additions & 6 deletions src/Services/FileMoverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) {
/// <returns>void</returns>
protected internal void QueueFileMove(MessageFormats.HostServices.Link.LinkResponse linkResponse) {
try {
_logger.LogTrace("Adding LinkRequest to queue. (trackingId: '{trackingId}' / correlationId: '{correlationId}')", linkResponse.ResponseHeader.TrackingId, linkResponse.ResponseHeader.CorrelationId);
_logger.LogTrace("Adding LinkRequest to queue. (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", linkResponse.ResponseHeader.TrackingId, linkResponse.ResponseHeader.CorrelationId, linkResponse.ResponseHeader.Status);
_linkResponseQueue.Add(linkResponse);
} catch (Exception ex) {
_logger.LogError("Failure storing LinkRequest to queue (trackingId: '{trackingId}' / correlationId: '{correlationId}'). Error: {errorMessage}", linkResponse.ResponseHeader.TrackingId, linkResponse.ResponseHeader.CorrelationId, ex.Message);
_logger.LogError("Failure storing LinkRequest to queue (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status '{status}'). Error: {errorMessage}", linkResponse.ResponseHeader.TrackingId, linkResponse.ResponseHeader.CorrelationId, linkResponse.ResponseHeader.Status, ex.Message);
}
}

Expand All @@ -260,18 +260,18 @@ private Task SendResponseToApps(MessageFormats.HostServices.Link.LinkResponse me
return Task.Run(async () => {
MessageFormats.HostServices.Link.LinkResponse? pluginResponse = message;
MessageFormats.HostServices.Link.LinkRequest? pluginRequest = message.LinkRequest;
_logger.LogDebug("Passing message '{messageType}' and '{responseType}' to plugins (trackingId: '{trackingId}' / correlationId: '{correlationId}')", message.GetType().Name, message.LinkRequest.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId);
_logger.LogDebug("Passing message '{messageType}' and '{responseType}' to plugins (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", message.GetType().Name, message.LinkRequest.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId, message.ResponseHeader.Status);

(MessageFormats.HostServices.Link.LinkRequest? output_request, MessageFormats.HostServices.Link.LinkResponse? output_response) =
_pluginLoader.CallPlugins<MessageFormats.HostServices.Link.LinkRequest?, Plugins.PluginBase, MessageFormats.HostServices.Link.LinkResponse>(
orig_request: pluginRequest, orig_response: pluginResponse,
pluginDelegate: _pluginDelegates.LinkResponse);


_logger.LogDebug("Plugins finished processing '{messageType}' and '{responseType}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", message.GetType().Name, message.LinkRequest.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId);
_logger.LogDebug("Plugins finished processing '{messageType}' and '{responseType}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", message.GetType().Name, message.LinkRequest.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId, message.ResponseHeader.Status);

if (output_response == null || output_request == null) {
_logger.LogInformation("Plugins nullified '{messageType}' or '{output_requestMessageType}'. Dropping Message (trackingId: '{trackingId}' / correlationId: '{correlationId}')", message.LinkRequest.GetType().Name, message.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId);
_logger.LogInformation("Plugins nullified '{messageType}' or '{output_requestMessageType}'. Dropping Message (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", message.LinkRequest.GetType().Name, message.GetType().Name, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId, message.ResponseHeader.Status);
return;
}

Expand All @@ -284,7 +284,7 @@ private Task SendResponseToApps(MessageFormats.HostServices.Link.LinkResponse me
return;
}

_logger.LogInformation("Sending successful '{messageType}' to '{sourceAppId}' and '{destinationAppId}' (trackingId: '{trackingId}' / correlationId: '{correlationId}')", message.GetType().Name, message.LinkRequest.RequestHeader.AppId, message.LinkRequest.DestinationAppId, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId);
_logger.LogInformation("Sending successful '{messageType}' to '{sourceAppId}' and '{destinationAppId}' (trackingId: '{trackingId}' / correlationId: '{correlationId}' / status: '{status}')", message.GetType().Name, message.LinkRequest.RequestHeader.AppId, message.LinkRequest.DestinationAppId, message.ResponseHeader.TrackingId, message.ResponseHeader.CorrelationId, message.ResponseHeader.Status);
await _client.DirectToApp(appId: message.LinkRequest.RequestHeader.AppId, message: message);
await _client.DirectToApp(appId: message.LinkRequest.DestinationAppId, message: message);
});
Expand Down

0 comments on commit 5d82483

Please # to comment.