-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7f1045
commit f3653f7
Showing
5 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Product.API.Controllers; | ||
|
||
public sealed class ProductController | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Src/Product.Application/Shared/Behaviors/LoggingBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using MediatR; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Product.Application.Shared.Behaviors; | ||
|
||
public sealed class LoggingBehavior<TRequest , TResponse> : IPipelineBehavior<TRequest , TResponse> | ||
where TRequest : IRequest<TResponse> | ||
{ | ||
private readonly ILogger _logger; | ||
public LoggingBehavior(ILogger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, | ||
CancellationToken cancellationToken) | ||
{ | ||
try | ||
{ | ||
return await next(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex.Message, ex); | ||
throw; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters