@@ -11,21 +11,19 @@ namespace Cofoundry.Plugins.ErrorLogging
11
11
public class ErrorLoggingMiddleware
12
12
{
13
13
private readonly RequestDelegate _next ;
14
- private readonly IErrorLoggingService _errorLoggingService ;
15
- private readonly ILogger < ErrorLoggingMiddleware > _logger ;
16
14
17
15
public ErrorLoggingMiddleware (
18
- RequestDelegate next ,
19
- ILogger < ErrorLoggingMiddleware > logger ,
20
- IErrorLoggingService errorLoggingService
16
+ RequestDelegate next
21
17
)
22
18
{
23
19
_next = next ;
24
- _logger = logger ;
25
- _errorLoggingService = errorLoggingService ;
26
20
}
27
21
28
- public async Task Invoke ( HttpContext context )
22
+ public async Task Invoke (
23
+ HttpContext context ,
24
+ ILogger < ErrorLoggingMiddleware > logger ,
25
+ IErrorLoggingService errorLoggingService
26
+ )
29
27
{
30
28
try
31
29
{
@@ -35,14 +33,14 @@ public async Task Invoke(HttpContext context)
35
33
{
36
34
try
37
35
{
38
- await _errorLoggingService . LogAsync ( ex ) ;
36
+ await errorLoggingService . LogAsync ( ex ) ;
39
37
}
40
38
catch ( Exception loggingEx )
41
39
{
42
40
// The original exception should still be logged by the outer handler, here we
43
41
// just log loggingEx
44
42
var msg = "An error occured logging exception {0} using handler type {1}" ;
45
- _logger . LogError ( 0 , loggingEx , msg , ex . GetType ( ) . FullName , _errorLoggingService . GetType ( ) . FullName ) ;
43
+ logger . LogError ( 0 , loggingEx , msg , ex . GetType ( ) . FullName , errorLoggingService . GetType ( ) . FullName ) ;
46
44
}
47
45
48
46
throw ;
0 commit comments