1
1
using System . Collections . Concurrent ;
2
2
3
+ using log4net ;
4
+
3
5
using Microsoft . EntityFrameworkCore ;
4
6
5
7
using Nullinside . Api . Common . Twitch ;
@@ -42,7 +44,7 @@ public class MainService : BackgroundService {
42
44
/// <summary>
43
45
/// The logger.
44
46
/// </summary>
45
- private readonly ILogger < MainService > _log ;
47
+ private readonly ILog _log = LogManager . GetLogger ( typeof ( MainService ) ) ;
46
48
47
49
/// <summary>
48
50
/// A collection of all bans received.
@@ -80,10 +82,8 @@ public class MainService : BackgroundService {
80
82
/// <summary>
81
83
/// Initializes a new instance of the <see cref="MainService" /> class.
82
84
/// </summary>
83
- /// <param name="logger">The logger.</param>
84
85
/// <param name="serviceScopeFactory">The service scope factory.</param>
85
- public MainService ( ILogger < MainService > logger , IServiceScopeFactory serviceScopeFactory ) {
86
- _log = logger ;
86
+ public MainService ( IServiceScopeFactory serviceScopeFactory ) {
87
87
_serviceScopeFactory = serviceScopeFactory ;
88
88
_scope = _serviceScopeFactory . CreateScope ( ) ;
89
89
_db = _scope . ServiceProvider . GetRequiredService < NullinsideContext > ( ) ;
@@ -116,7 +116,7 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) {
116
116
await Main ( stoppingToken ) ;
117
117
}
118
118
catch ( Exception ex ) {
119
- _log . LogError ( ex , "Main Failed" ) ;
119
+ _log . Error ( "Main Failed" , ex ) ;
120
120
await Task . Delay ( TimeSpan . FromSeconds ( 10 ) , stoppingToken ) ;
121
121
}
122
122
}
@@ -179,7 +179,7 @@ private async Task Main(CancellationToken stoppingToken) {
179
179
await DoScan ( user , botUser , stoppingToken ) ;
180
180
}
181
181
catch ( Exception ex ) {
182
- _log . LogError ( ex , $ "Scan failed for { user . TwitchUsername } ") ;
182
+ _log . Error ( $ "Scan failed for { user . TwitchUsername } ", ex ) ;
183
183
}
184
184
} ) ;
185
185
}
@@ -190,7 +190,7 @@ private async Task Main(CancellationToken stoppingToken) {
190
190
}
191
191
}
192
192
catch ( Exception ex ) {
193
- _log . LogError ( ex , "Main Inner failed" ) ;
193
+ _log . Error ( "Main Inner failed" , ex ) ;
194
194
}
195
195
}
196
196
@@ -297,7 +297,7 @@ private async Task DoScan(User user, User botUser, CancellationToken stoppingTok
297
297
}
298
298
}
299
299
catch ( Exception e ) {
300
- _log . LogError ( e , $ "{ user . TwitchUsername } : Failed to evaluate rule") ;
300
+ _log . Error ( $ "{ user . TwitchUsername } : Failed to evaluate rule", e ) ;
301
301
}
302
302
}
303
303
0 commit comments