Skip to content

Commit 6c8454b

Browse files
Converting missed microsoft logger references to log4net
Previous work in: 281101c
1 parent 6bfb5c6 commit 6c8454b

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/Nullinside.Api.TwitchBot/Controllers/BotController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Security.Claims;
22

3+
using log4net;
4+
35
using Microsoft.AspNetCore.Mvc;
46
using Microsoft.EntityFrameworkCore;
57

@@ -32,16 +34,14 @@ public class BotController : ControllerBase {
3234
/// <summary>
3335
/// The logger.
3436
/// </summary>
35-
private readonly ILogger<BotController> _logger;
37+
private readonly ILog _log = LogManager.GetLogger(typeof(BotController));
3638

3739
/// <summary>
3840
/// Initializes a new instance of the <see cref="LoginController" /> class.
3941
/// </summary>
40-
/// <param name="logger">The logger.</param>
4142
/// <param name="dbContext">The nullinside database.</param>
4243
/// <param name="configuration">The application's configuration.</param>
43-
public BotController(ILogger<BotController> logger, NullinsideContext dbContext, IConfiguration configuration) {
44-
_logger = logger;
44+
public BotController(NullinsideContext dbContext, IConfiguration configuration) {
4545
_dbContext = dbContext;
4646
_configuration = configuration;
4747
}

src/Nullinside.Api.TwitchBot/Controllers/LoginController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using log4net;
2+
13
using Microsoft.AspNetCore.Authorization;
24
using Microsoft.AspNetCore.Mvc;
35

@@ -26,16 +28,14 @@ public class LoginController : ControllerBase {
2628
/// <summary>
2729
/// The logger.
2830
/// </summary>
29-
private readonly ILogger<LoginController> _logger;
31+
private readonly ILog _log = LogManager.GetLogger(typeof(LoginController));
3032

3133
/// <summary>
3234
/// Initializes a new instance of the <see cref="LoginController" /> class.
3335
/// </summary>
34-
/// <param name="logger">The logger.</param>
3536
/// <param name="dbContext">The nullinside database.</param>
3637
/// <param name="configuration">The application's configuration.</param>
37-
public LoginController(ILogger<LoginController> logger, NullinsideContext dbContext, IConfiguration configuration) {
38-
_logger = logger;
38+
public LoginController(NullinsideContext dbContext, IConfiguration configuration) {
3939
_dbContext = dbContext;
4040
_configuration = configuration;
4141
}

src/Nullinside.Api.TwitchBot/Nullinside.Api.TwitchBot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ItemGroup>
2424
<PackageReference Include="log4net.Ext.Json" Version="2.0.10.1"/>
2525
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
26-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
26+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
2727
<PrivateAssets>all</PrivateAssets>
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>

src/Nullinside.Api.TwitchBot/Services/MainService.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Collections.Concurrent;
22

3+
using log4net;
4+
35
using Microsoft.EntityFrameworkCore;
46

57
using Nullinside.Api.Common.Twitch;
@@ -42,7 +44,7 @@ public class MainService : BackgroundService {
4244
/// <summary>
4345
/// The logger.
4446
/// </summary>
45-
private readonly ILogger<MainService> _log;
47+
private readonly ILog _log = LogManager.GetLogger(typeof(MainService));
4648

4749
/// <summary>
4850
/// A collection of all bans received.
@@ -80,10 +82,8 @@ public class MainService : BackgroundService {
8082
/// <summary>
8183
/// Initializes a new instance of the <see cref="MainService" /> class.
8284
/// </summary>
83-
/// <param name="logger">The logger.</param>
8485
/// <param name="serviceScopeFactory">The service scope factory.</param>
85-
public MainService(ILogger<MainService> logger, IServiceScopeFactory serviceScopeFactory) {
86-
_log = logger;
86+
public MainService(IServiceScopeFactory serviceScopeFactory) {
8787
_serviceScopeFactory = serviceScopeFactory;
8888
_scope = _serviceScopeFactory.CreateScope();
8989
_db = _scope.ServiceProvider.GetRequiredService<NullinsideContext>();
@@ -116,7 +116,7 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) {
116116
await Main(stoppingToken);
117117
}
118118
catch (Exception ex) {
119-
_log.LogError(ex, "Main Failed");
119+
_log.Error("Main Failed", ex);
120120
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
121121
}
122122
}
@@ -179,7 +179,7 @@ private async Task Main(CancellationToken stoppingToken) {
179179
await DoScan(user, botUser, stoppingToken);
180180
}
181181
catch (Exception ex) {
182-
_log.LogError(ex, $"Scan failed for {user.TwitchUsername}");
182+
_log.Error($"Scan failed for {user.TwitchUsername}", ex);
183183
}
184184
});
185185
}
@@ -190,7 +190,7 @@ private async Task Main(CancellationToken stoppingToken) {
190190
}
191191
}
192192
catch (Exception ex) {
193-
_log.LogError(ex, "Main Inner failed");
193+
_log.Error("Main Inner failed", ex);
194194
}
195195
}
196196

@@ -297,7 +297,7 @@ private async Task DoScan(User user, User botUser, CancellationToken stoppingTok
297297
}
298298
}
299299
catch (Exception e) {
300-
_log.LogError(e, $"{user.TwitchUsername}: Failed to evaluate rule");
300+
_log.Error($"{user.TwitchUsername}: Failed to evaluate rule", e);
301301
}
302302
}
303303

0 commit comments

Comments
 (0)