stuff
This commit is contained in:
parent
14fd359ea8
commit
a4ef2b4a20
26 changed files with 331 additions and 78 deletions
|
@ -9,6 +9,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||
<PackageReference Include="Quartz" Version="3.14.0" />
|
||||
|
|
19
Femto.Common/Infrastructure/DomainServiceExtensions.cs
Normal file
19
Femto.Common/Infrastructure/DomainServiceExtensions.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Femto.Common.Infrastructure;
|
||||
|
||||
public static class DomainServiceExtensions
|
||||
{
|
||||
public static void ConfigureDomainServices<TContext>(this IServiceCollection services)
|
||||
where TContext : DbContext
|
||||
{
|
||||
services.AddScoped<DbContext>(s => s.GetRequiredService<TContext>());
|
||||
services.AddTransient(
|
||||
typeof(IPipelineBehavior<,>),
|
||||
typeof(SaveChangesPipelineBehaviour<,>)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
37
Femto.Common/Logs/LoggerExtensions.cs
Normal file
37
Femto.Common/Logs/LoggerExtensions.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Femto.Common.Logs;
|
||||
|
||||
public static partial class LoggerExtensions
|
||||
{
|
||||
[LoggerMessage(
|
||||
LogLevel.Error,
|
||||
EventId = 1,
|
||||
EventName = "FailedRequestWithException",
|
||||
Message = "Request failed: {Method} {Path}, Status: {StatusCode}, TraceId: {TraceId}, Message: {Message}"
|
||||
)]
|
||||
public static partial void LogFailedRequest(
|
||||
this ILogger logger,
|
||||
Exception exception,
|
||||
string method,
|
||||
string path,
|
||||
int statusCode,
|
||||
string traceId,
|
||||
string message
|
||||
);
|
||||
|
||||
[LoggerMessage(
|
||||
LogLevel.Error,
|
||||
EventId = 2,
|
||||
EventName = "FailedRequest",
|
||||
Message = "Request failed: {Method} {Path}, Status: {StatusCode}, TraceId: {TraceId}, Message: {Message}"
|
||||
)]
|
||||
public static partial void LogFailedRequest(
|
||||
this ILogger logger,
|
||||
string method,
|
||||
string path,
|
||||
int statusCode,
|
||||
string traceId,
|
||||
string message
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue