Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkidu93 committed Nov 7, 2023
1 parent 9619a53 commit efe43ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Serval.Shared/Controllers/ErrorResultFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public ErrorResultFilter(ILoggerFactory loggerFactory)
_logger = loggerFactory.CreateLogger<ErrorResultFilter>();
}

public void OnResultExecuted(ResultExecutedContext context) { }

public void OnResultExecuting(ResultExecutingContext context)
public void OnResultExecuted(ResultExecutedContext context)
{
if ((context.Result is ObjectResult r) && (r.StatusCode >= 400))
if (context.HttpContext.Response.StatusCode >= 400)
{
_logger.LogInformation(
$"Client {((Controller)context.Controller).User.Identity?.Name?.ToString()} made request:\n {JsonSerializer.Serialize(((Controller)context.Controller).ControllerContext.RouteData.Values, new JsonSerializerOptions { WriteIndented = true })}.\n Serval responded with code {r.StatusCode}. Trace: {Activity.Current?.Id}"
$"Client {((Controller)context.Controller).User.Identity?.Name?.ToString()} made request:\n {JsonSerializer.Serialize(((Controller)context.Controller).ControllerContext.RouteData.Values, new JsonSerializerOptions { WriteIndented = true })}.\n Serval responded with code {context.HttpContext.Response.StatusCode}. Trace: {Activity.Current?.Id}"
);
}
}

public void OnResultExecuting(ResultExecutingContext context) { }
}
}

0 comments on commit efe43ba

Please sign in to comment.