blob: 002adda85e63fa05a740ac5721efb60ead278e60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
namespace LibraryAPI.Filters {
public class ActionFilter : IActionFilter {
private readonly ILogger<ActionFilter> log;
public ActionFilter(ILogger<ActionFilter> log) {
this.log = log;
}
public void OnActionExecuting(ActionExecutingContext context) {
string log_string = $@"Got request {context.HttpContext.Request.Method} {context.HttpContext.Request.Path}";
log.LogInformation("Before Action\n" + log_string);
}
public void OnActionExecuted(ActionExecutedContext context) {
log.LogInformation("After Action");
}
}
}
|