chore(logging): Migrate some logs to ILogger (#582)
This commit is contained in:
parent
421d852991
commit
c6cbda6f52
16 changed files with 103 additions and 76 deletions
|
|
@ -19,11 +19,14 @@ using System.Text.Json;
|
|||
using System.Text.Json.Serialization;
|
||||
using MimeKit;
|
||||
using Server.Json;
|
||||
using Server.Logging;
|
||||
|
||||
namespace Server.Configurations
|
||||
{
|
||||
public static class EmailConfiguration
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(EmailConfiguration));
|
||||
|
||||
private const string m_RelPath = "Configuration/email-settings.json";
|
||||
|
||||
public static MailboxAddress CrashAddress { get; private set; }
|
||||
|
|
@ -45,28 +48,21 @@ namespace Server.Configurations
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Console.Write($"Core: Reading email configuration from {m_RelPath}...");
|
||||
settings = JsonConfig.Deserialize<Settings>(path);
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
Utility.PushColor(ConsoleColor.Red);
|
||||
Console.WriteLine("failed");
|
||||
Utility.PopColor();
|
||||
logger.Error($"Failed reading email configuration from {m_RelPath}");
|
||||
throw new JsonException($"Failed to deserialize {path}.");
|
||||
}
|
||||
|
||||
Utility.PushColor(ConsoleColor.Green);
|
||||
Console.WriteLine("done");
|
||||
Utility.PopColor();
|
||||
logger.Information($"Email configuration read from {m_RelPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
settings = new Settings();
|
||||
JsonConfig.Serialize(path, settings);
|
||||
Utility.PushColor(ConsoleColor.Green);
|
||||
Console.WriteLine($"Core: Email Configuration saved to {m_RelPath}.");
|
||||
Utility.PopColor();
|
||||
logger.Information($"Email configuration saved to {m_RelPath}.");
|
||||
}
|
||||
|
||||
EmailEnabled = settings.enabled;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue