Skip to content

Commit

Permalink
Fix broken logging in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
NixFey committed Dec 25, 2024
1 parent c170a5c commit f355113
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Options;

namespace FiMAdminApi;
namespace FiMAdminApi.Auth;

public class EventSyncAuthHandler : AuthenticationHandler<EventSyncAuthOptions>
{
Expand Down
6 changes: 4 additions & 2 deletions FiMAdminApi/Endpoints/EventSyncEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Asp.Versioning.Builder;
using FiMAdminApi.Auth;
using FiMAdminApi.Clients;
using FiMAdminApi.Data;
using FiMAdminApi.EventSync;
Expand Down Expand Up @@ -52,7 +53,7 @@ private static async Task<Results<Ok<EventSyncResult>, NotFound, BadRequest<stri
}

private static async Task<Ok<EventSyncResult>> SyncCurrentEvents([FromServices] DataContext context,
[FromServices] EventSyncService syncService, [FromServices] ILogger logger)
[FromServices] EventSyncService syncService, [FromServices] ILoggerFactory loggerFactory)
{
var events = context.Events.Include(e => e.Season).Where(e =>
e.SyncSource != null && e.StartTime <= DateTime.UtcNow && e.EndTime >= DateTime.UtcNow).AsAsyncEnumerable();
Expand All @@ -67,7 +68,8 @@ private static async Task<Ok<EventSyncResult>> SyncCurrentEvents([FromServices]
var individualResult = await syncService.SyncEvent(e);
if (!individualResult.Success)
{
logger.LogWarning("Sync for event {EventCode} failed: {Message}", e.Code ?? e.Id.ToString(),
loggerFactory.CreateLogger(typeof(EventSyncEndpoints)).LogWarning(
"Sync for event {EventCode} failed: {Message}", e.Code ?? e.Id.ToString(),
individualResult.Message ?? "No message provided");
lock (successLock)
{
Expand Down

0 comments on commit f355113

Please sign in to comment.