Updated packages

This commit is contained in:
2023-03-24 12:12:44 +01:00
parent ae6c321b88
commit a592aabef1
2 changed files with 31 additions and 41 deletions

View File

@@ -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);
}
}