Updated packages
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
using EonaCat.Logger.Helpers;
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Runtime;
|
||||
|
||||
namespace EonaCat.Logger.Extensions
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Extensions
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using EonaCat.Logger.Internal;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using EonaCat.Logger.EonaCatCoreLogger.Internal;
|
||||
|
||||
namespace EonaCat.Logger
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using EonaCat.Logger.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using EonaCat.Logger.EonaCatCoreLogger.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EonaCat.Logger
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
@@ -27,10 +26,10 @@ namespace EonaCat.Logger
|
||||
private readonly int _maxRolloverFiles;
|
||||
private readonly int _maxTries;
|
||||
private int _rollOverCount = 0;
|
||||
private static readonly object _writeLock = new object();
|
||||
private static readonly object _rollOverLock = new object();
|
||||
private static readonly object WriteLock = new object();
|
||||
private static readonly object RollOverLock = new object();
|
||||
private string _logFile;
|
||||
private bool rollingOver;
|
||||
private bool _rollingOver;
|
||||
|
||||
/// <summary>
|
||||
/// The file to which log messages should be appended.
|
||||
@@ -95,26 +94,26 @@ namespace EonaCat.Logger
|
||||
File.Delete(rollOverFile);
|
||||
}
|
||||
fileInfo.CopyTo(rollOverFile);
|
||||
File.WriteAllText(LogFile, string.Empty);
|
||||
await File.WriteAllTextAsync(LogFile, string.Empty, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (_rollOverLock)
|
||||
lock (RollOverLock)
|
||||
{
|
||||
rollingOver = true;
|
||||
_rollingOver = true;
|
||||
MoveRolloverLogFiles();
|
||||
rollingOver = false;
|
||||
_rollingOver = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (rollingOver)
|
||||
while (_rollingOver)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
lock (_writeLock)
|
||||
lock (WriteLock)
|
||||
{
|
||||
int tries = 0;
|
||||
bool completed = false;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using EonaCat.logger.Managers;
|
||||
using System;
|
||||
using EonaCat.Logger.EonaCatCoreLogger.Models;
|
||||
using EonaCat.Logger.Managers;
|
||||
using EonaCatLogger.EonaCatCoreLogger.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace EonaCat.Logger.Internal
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Internal
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
@@ -49,18 +48,16 @@ namespace EonaCat.Logger.Internal
|
||||
|
||||
_provider.AddMessage(timestamp, message);
|
||||
|
||||
var EonaCatMessage = new EonaCatLogMessage
|
||||
var currentMessage = new EonaCatLogMessage
|
||||
{
|
||||
DateTime = timestamp.DateTime,
|
||||
Message = message,
|
||||
LogType = logLevel.FromLogLevel()
|
||||
};
|
||||
|
||||
if (_loggerSettings != null)
|
||||
{
|
||||
EonaCatMessage.Origin = string.IsNullOrWhiteSpace(_loggerSettings.LogOrigin) ? "BatchingLogger" : _loggerSettings.LogOrigin;
|
||||
_loggerSettings?.OnLogEvent(EonaCatMessage);
|
||||
}
|
||||
if (_loggerSettings == null) return;
|
||||
currentMessage.Origin = string.IsNullOrWhiteSpace(_loggerSettings.LogOrigin) ? "BatchingLogger" : _loggerSettings.LogOrigin;
|
||||
_loggerSettings?.OnLogEvent(currentMessage);
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace EonaCat.Logger.Internal
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Internal
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using EonaCat.Logger.Helpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EonaCat.Logger.Internal
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Internal
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
@@ -39,9 +38,9 @@ namespace EonaCat.Logger.Internal
|
||||
|
||||
protected abstract Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token);
|
||||
|
||||
private async Task ProcessLogQueue(object state)
|
||||
private async Task ProcessLogQueueAsync(object state)
|
||||
{
|
||||
await WriteMessagesAsync(new List<LogMessage> { new LogMessage { Message = $"[{DllInfo.ApplicationName}] {DllInfo.ApplicationName} started.{Environment.NewLine}", Timestamp = DateTimeOffset.Now } }, _cancellationTokenSource.Token);
|
||||
await WriteMessagesAsync(new List<LogMessage> { new LogMessage { Message = $"[{DllInfo.ApplicationName}] {DllInfo.ApplicationName} started.{Environment.NewLine}", Timestamp = DateTimeOffset.Now } }, _cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
while (!_cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
int limit = _batchSize <= 0 ? int.MaxValue : _batchSize;
|
||||
@@ -57,7 +56,7 @@ namespace EonaCat.Logger.Internal
|
||||
bool isBatchWritten = false;
|
||||
try
|
||||
{
|
||||
await WriteMessagesAsync(_currentBatch, _cancellationTokenSource.Token);
|
||||
await WriteMessagesAsync(_currentBatch, _cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
isBatchWritten = true;
|
||||
}
|
||||
catch
|
||||
@@ -71,9 +70,9 @@ namespace EonaCat.Logger.Internal
|
||||
}
|
||||
}
|
||||
|
||||
await IntervalAsync(_interval, _cancellationTokenSource.Token);
|
||||
await IntervalAsync(_interval, _cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
await WriteMessagesAsync(new List<LogMessage> { new LogMessage { Message = $"[{DllInfo.ApplicationName}] {DllInfo.ApplicationName} stopped.{Environment.NewLine}", Timestamp = DateTimeOffset.Now } }, _cancellationTokenSource.Token);
|
||||
await WriteMessagesAsync(new List<LogMessage> { new LogMessage { Message = $"[{DllInfo.ApplicationName}] {DllInfo.ApplicationName} stopped.{Environment.NewLine}", Timestamp = DateTimeOffset.Now } }, _cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected virtual Task IntervalAsync(TimeSpan interval, CancellationToken cancellationToken)
|
||||
@@ -92,18 +91,18 @@ namespace EonaCat.Logger.Internal
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
_outputTask = Task.Factory.StartNew(
|
||||
ProcessLogQueue,
|
||||
ProcessLogQueueAsync,
|
||||
null,
|
||||
TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
private void Stop()
|
||||
private async Task StopAsync()
|
||||
{
|
||||
_cancellationTokenSource.Cancel();
|
||||
|
||||
try
|
||||
{
|
||||
_outputTask.Wait(_interval);
|
||||
await _outputTask.ConfigureAwait(false);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
@@ -115,7 +114,9 @@ namespace EonaCat.Logger.Internal
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Stop();
|
||||
#pragma warning disable CS4014
|
||||
StopAsync();
|
||||
#pragma warning restore CS4014
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace EonaCat.Logger.Internal
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Internal
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using EonaCat.Logger;
|
||||
using System;
|
||||
using EonaCat.Logger.Helpers;
|
||||
using System;
|
||||
|
||||
namespace EonaCatLogger.EonaCatCoreLogger.Models
|
||||
namespace EonaCat.Logger.EonaCatCoreLogger.Models
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
Reference in New Issue
Block a user