Updated Logger and Created Command to change settings variables

This commit is contained in:
2023-10-01 14:11:34 +03:00
parent f58a57c6cd
commit 6279c5c3a9
7 changed files with 139 additions and 5 deletions

View File

@@ -38,7 +38,7 @@ public sealed class Logger : ILogger
(UseShortVersion ? logMessage : logMessage.AsLongString()) + "\n");
}
public async Task Log(string message = "", string outputFile = "", Type? source = default, LogType type = LogType.INFO, DateTime throwTime = default)
public async void Log(string message = "", string outputFile = "", Type? source = default, LogType type = LogType.INFO, DateTime throwTime = default)
{
if (!IsEnabled) return;
@@ -53,5 +53,17 @@ public sealed class Logger : ILogger
if (source == default) source = typeof(Log);
await Log(new Log(message, outputFile, source, type, throwTime));
}
public async void Log(Exception exception, LogType logType = LogType.ERROR, Type? source = null)
{
if (!IsEnabled) return;
if (logType < LowestLogLevel) return;
await Log(new Log(exception.Message,
Config.AppSettings["LogFolder"] + "/" + DateTime.Now.ToString("yyyy-MM-dd") + ".log",
source, logType, DateTime.Now));
}
}