diff --git a/Logger.cs b/Logger.cs
index 25f3120..79a44ad 100644
--- a/Logger.cs
+++ b/Logger.cs
@@ -134,11 +134,14 @@ public class Logger : ILogger
try
{
- Byte[] FileWrite = Encoding.UTF8.GetBytes($"[{currentLog.TimeOfEvent:dd.MM.yyyy HH:mm:ss}] [{LogLevelText}] {LogMessage}\n{(currentLog.Exception is not null ? $"{currentLog.Exception}\n" : "")}");
- if (OpenedFile != null)
+ if (!_loggerObjects.FileBlackList.Contains(currentLog.LogLevel))
{
- await OpenedFile.WriteAsync(FileWrite.AsMemory(0, FileWrite.Length));
- OpenedFile.Flush();
+ Byte[] FileWrite = Encoding.UTF8.GetBytes($"[{currentLog.TimeOfEvent:dd.MM.yyyy HH:mm:ss}] [{LogLevelText}] {LogMessage}\n{(currentLog.Exception is not null ? $"{currentLog.Exception}\n" : "")}");
+ if (OpenedFile != null)
+ {
+ await OpenedFile.WriteAsync(FileWrite.AsMemory(0, FileWrite.Length));
+ OpenedFile.Flush();
+ }
}
}
catch (Exception ex)
@@ -191,6 +194,15 @@ public class Logger : ILogger
{
_loggerObjects.Blacklist.Add(blacklist);
}
+
+ ///
+ /// Add blacklisted log level to not save
+ ///
+ ///
+ public static void AddLogLevelBlacklist(LoggerObjects.LogLevel level)
+ {
+ _loggerObjects.FileBlackList.Add(level);
+ }
@@ -365,7 +377,7 @@ public class Logger : ILogger
LogLevel = logLevel switch
{
Microsoft.Extensions.Logging.LogLevel.Debug => LoggerObjects.LogLevel.DEBUG2,
- Microsoft.Extensions.Logging.LogLevel.Trace => LoggerObjects.LogLevel.TRACE,
+ Microsoft.Extensions.Logging.LogLevel.Trace => LoggerObjects.LogLevel.TRACE2,
Microsoft.Extensions.Logging.LogLevel.Information => LoggerObjects.LogLevel.INFO,
Microsoft.Extensions.Logging.LogLevel.Warning => LoggerObjects.LogLevel.WARN,
Microsoft.Extensions.Logging.LogLevel.Error => LoggerObjects.LogLevel.ERROR,
diff --git a/LoggerObjects.cs b/LoggerObjects.cs
index 3f3e147..08a26c6 100644
--- a/LoggerObjects.cs
+++ b/LoggerObjects.cs
@@ -4,6 +4,7 @@ public class LoggerObjects
{
internal List LogsToPost = new();
internal List Blacklist = new();
+ internal List FileBlackList = new();
public class LogEntry
{
@@ -22,6 +23,7 @@ public class LoggerObjects
INFO,
DEBUG,
DEBUG2,
- TRACE
+ TRACE,
+ TRACE2
}
}