diff --git a/ECMJobRunner.Application/Profiles/Commands/Behaviors/JobExceptionHandlingBehavior.cs b/ECMJobRunner.Application/Profiles/Commands/Behaviors/JobExceptionHandlingBehavior.cs
index 80e3177..6f51df9 100644
--- a/ECMJobRunner.Application/Profiles/Commands/Behaviors/JobExceptionHandlingBehavior.cs
+++ b/ECMJobRunner.Application/Profiles/Commands/Behaviors/JobExceptionHandlingBehavior.cs
@@ -2,6 +2,7 @@
using ECMJobRunner.Application.ProfileHistories.Commands;
using ECMJobRunner.Domain.ValueObjects;
using MediatR;
+using Microsoft.Extensions.Logging;
using System.Threading;
using System.Threading.Tasks;
@@ -14,7 +15,8 @@ namespace ECMJobRunner.Application.Profiles.Commands.Behaviors;
/// The type of the MediatR request
/// The type of the MediatR response
/// MediatR sender used to dispatch the
-public class JobExceptionHandlingBehavior(ISender Sender) : IPipelineBehavior where TRequest : notnull
+/// Logger for diagnostic output.
+public class JobExceptionHandlingBehavior(ISender Sender, ILogger> Logger) : IPipelineBehavior where TRequest : notnull
{
///
/// Handles the pipeline behavior
@@ -36,12 +38,14 @@ public class JobExceptionHandlingBehavior(ISender Sender) :
{
ProfileId = ex.ProfileId,
Result = ResultType.Ok,
- ResultText = ex.Message,
+ ResultText = ex.ToString(),
AddedWho = "ECMJobRunner"
};
await Sender.Send(cmd, cancellationToken);
- throw;
+ Logger.LogWarning(ex, "JobException caught in JobExceptionHandlingBehavior for ProfileId {ProfileId}, JobName {JobName}, ProcessName {ProcessName}, BatchId {BatchId}", ex.ProfileId, ex.JobName, ex.ProcessName, ex.BatchId);
+
+ return default!;
}
}
}
diff --git a/ECMJobRunner.Application/Profiles/Commands/Behaviors/ReCRequestExecutionBehavior.cs b/ECMJobRunner.Application/Profiles/Commands/Behaviors/ReCRequestExecutionBehavior.cs
index 263bebc..f420a6a 100644
--- a/ECMJobRunner.Application/Profiles/Commands/Behaviors/ReCRequestExecutionBehavior.cs
+++ b/ECMJobRunner.Application/Profiles/Commands/Behaviors/ReCRequestExecutionBehavior.cs
@@ -3,6 +3,7 @@ using ECMJobRunner.Application.Common.Exceptions;
using ECMJobRunner.Application.Common.Options;
using ECMJobRunner.Application.Profiles.Commands;
using MediatR;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ReC.Client;
using ReC.Client.Api;
@@ -18,22 +19,15 @@ namespace ECMJobRunner.Application.Profiles.Commands.Behaviors
///
/// The request type
/// The response type
- public class ReCRequestExecutionBehavior : IPipelineBehavior
+ ///
+ /// Initializes a new instance of ReCRequestExecutionBehavior
+ ///
+ /// ReC client for HTTP requests
+ /// DEX job configuration options
+ public class ReCRequestExecutionBehavior(ReCClient ReCClient, IOptions options, ILogger> Logger) : IPipelineBehavior
where TRequest : notnull
{
- private readonly ReCClient _reCClient;
- private readonly DexJobOptions _options;
-
- ///
- /// Initializes a new instance of ReCRequestExecutionBehavior
- ///
- /// ReC client for HTTP requests
- /// DEX job configuration options
- public ReCRequestExecutionBehavior(ReCClient reCClient, IOptions options)
- {
- _reCClient = reCClient;
- _options = options.Value;
- }
+ private readonly DexJobOptions Options = options.Value;
///
/// Handles the pipeline behavior
@@ -57,14 +51,23 @@ namespace ECMJobRunner.Application.Profiles.Commands.Behaviors
{
try
{
- await _reCClient.RecActions.InvokeAsync(command.Job.ProfileId, new InvokeReferences()
+ command.RecActionResult = await ReCClient.RecActions.InvokeAsync(command.Job.ProfileId, new InvokeReferences()
{
BatchId = command.BatchId,
}, cancel);
+
+ Logger.LogInformation(
+ "ReC request completed successfully. Profile ID: {ProfileId} | Job name: {JobName} | Batch ID: {BatchId} | Total action count: {TotalActionCount} | Action exception count: {ActionExceptionCount}",
+ command.Job.ProfileId,
+ command.Job.Name,
+ command.BatchId,
+ command.RecActionResult?.TotalActionCount ?? 0,
+ command.RecActionResult?.ActionExceptionCount ?? 0);
+
}
catch (Exception ex)
{
- if (_options.Error.ReCRequest.OnSending == ErrorAction.Stop)
+ if (Options.Error.ReCRequest.OnSending == ErrorAction.Stop)
{
throw new JobHttpException(
profileId: command.Job.ProfileId,