diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-01-16 17:28:09 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-01-16 17:28:09 -0600 |
| commit | cc1381416d3bd71a9c77ff5b8793f33953f09ac6 (patch) | |
| tree | 3ab729fdf3e4091521e0ae5cb1bd688bcb52165b | |
| parent | 38edf59f32fb123d90f7b903edd3ddbbfab0d614 (diff) | |
| download | slskd-cc1381416d3bd71a9c77ff5b8793f33953f09ac6.tar.gz | |
log instead of console.write
| -rw-r--r-- | src/slskd/Startup.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index 6f5bc604..61993997 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -29,6 +29,7 @@ using System.Collections.Concurrent; using Serilog; using Serilog.Events; + using Microsoft.Extensions.Logging; public class Startup { @@ -178,6 +179,7 @@ public void Configure( IApplicationBuilder app, IWebHostEnvironment env, + ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider, ITransferTracker tracker, IBrowseTracker browseTracker, @@ -255,6 +257,8 @@ // begin SoulseekClient implementation // --------------------------------------------------------------------------------------------------------------------------------------------- + var logger = loggerFactory.CreateLogger<Startup>(); + var connectionOptions = new ConnectionOptions( readBufferSize: ReadBufferSize, writeBufferSize: WriteBufferSize, @@ -369,14 +373,14 @@ Client.Disconnected += async (e, args) => { - Console.WriteLine($"Disconnected from Soulseek server: {args.Message}"); + logger.LogWarning("Disconnected from Soulseek server: {Message}", args.Message, args.Exception); // don't reconnect if the disconnecting Exception is either of these types. // if KickedFromServerException, another client was most likely signed in, and retrying will cause a connect loop. // if ObjectDisposedException, the client is shutting down. if (!(args.Exception is KickedFromServerException || args.Exception is ObjectDisposedException)) { - Console.WriteLine($"Attepting to reconnect..."); + logger.LogWarning("Attepting to reconnect..."); await Client.ConnectAsync(Username, Password); } }; @@ -386,7 +390,7 @@ await Client.ConnectAsync(Username, Password); }).GetAwaiter().GetResult(); - Console.WriteLine($"Connected and logged in."); + logger.LogInformation("Connected and logged in as {Username}", Username); } /// <summary> |
