From a592aabef1754adba2c2ce939c9350d023238a8a Mon Sep 17 00:00:00 2001 From: EonaCat Date: Fri, 24 Mar 2023 12:12:44 +0100 Subject: [PATCH] Updated packages --- EonaCat.Logger/EonaCat.Logger.csproj | 6 +-- EonaCat.Logger/Managers/LogManager.cs | 66 ++++++++++++--------------- 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/EonaCat.Logger/EonaCat.Logger.csproj b/EonaCat.Logger/EonaCat.Logger.csproj index c727d7a..d954e3a 100644 --- a/EonaCat.Logger/EonaCat.Logger.csproj +++ b/EonaCat.Logger/EonaCat.Logger.csproj @@ -9,7 +9,7 @@ net7.0; icon.ico - 1.0.8 + 1.0.9 EonaCat (Jeroen Saey) true EonaCat (Jeroen Saey) @@ -46,8 +46,8 @@ - - + + diff --git a/EonaCat.Logger/Managers/LogManager.cs b/EonaCat.Logger/Managers/LogManager.cs index 0ea4470..8836bd5 100644 --- a/EonaCat.Logger/Managers/LogManager.cs +++ b/EonaCat.Logger/Managers/LogManager.cs @@ -19,7 +19,6 @@ namespace EonaCat.Logger.Managers public partial class LogManager : ILogManager, IDisposable { - private readonly object _batton = new object(); private DateTime _logDate; public ELogType LogType; private ILoggerProvider LoggerProvider { get; set; } @@ -30,7 +29,7 @@ namespace EonaCat.Logger.Managers public bool IsRunning { get; private set; } public StreamWriter Output { get; private set; } - + public string CategoryName { get; set; } public readonly string Id; @@ -77,21 +76,18 @@ namespace EonaCat.Logger.Managers protected virtual void Dispose(bool disposing) { - lock (this) + if (_disposed) { - if (_disposed) - { - return; - } - - if (disposing) - { - StopLogging(); - _TokenSource.Cancel(); - } - - _disposed = true; + return; } + + if (disposing) + { + StopLogging(); + _TokenSource.Cancel(); + } + + _disposed = true; } private void StartNewLog() @@ -184,10 +180,10 @@ namespace EonaCat.Logger.Managers Write(dateTime, remainder, logType, writeToConsole); } - var EonaCatMessage = new EonaCatLogMessage + var EonaCatMessage = new EonaCatLogMessage { - DateTime = dateTime, - Message = currentMessage, + DateTime = dateTime, + Message = currentMessage, LogType = logType }; @@ -235,7 +231,7 @@ namespace EonaCat.Logger.Managers } if (!settings.EnableFileLogging) return; - + if (logFolder != null) { Settings.FileLoggerOptions.LogDirectory = logFolder; @@ -295,32 +291,26 @@ namespace EonaCat.Logger.Managers public void Write(string message, ELogType logType = ELogType.INFO, bool? writeToConsole = null) { - lock (_batton) + if (logType == ELogType.NONE) { - if (logType == ELogType.NONE) - { - return; - } - - DateTime now = DateTime.Now; - - if (!IsRunning) - { - StartNewLog(); - } - - Write(now, message, logType, writeToConsole); + return; } + + DateTime now = DateTime.Now; + + if (!IsRunning) + { + StartNewLog(); + } + + Write(now, message, logType, writeToConsole); } public void DeleteCurrentLogFile() { - lock (this) + if (!string.IsNullOrWhiteSpace(CurrentLogFile)) { - if (!string.IsNullOrWhiteSpace(CurrentLogFile)) - { - File.Delete(CurrentLogFile); - } + File.Delete(CurrentLogFile); } }