Updated
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EonaCat.Logger.Helpers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Runtime;
|
||||
|
||||
namespace EonaCat.Logger.Extensions
|
||||
{
|
||||
|
||||
@@ -126,9 +126,8 @@ namespace EonaCat.Logger
|
||||
System.IO.StreamWriter file = new System.IO.StreamWriter(LogFile, true);
|
||||
foreach (LogMessage item in group)
|
||||
{
|
||||
file.WriteAsync(item.Message);
|
||||
file.Write(item.Message);
|
||||
}
|
||||
|
||||
file.Close();
|
||||
completed = true;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using EonaCat.logger.Managers;
|
||||
using EonaCat.Logger.Managers;
|
||||
using EonaCatLogger.EonaCatCoreLogger.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime;
|
||||
|
||||
namespace EonaCat.Logger.Internal
|
||||
{
|
||||
@@ -48,6 +49,19 @@ namespace EonaCat.Logger.Internal
|
||||
}
|
||||
|
||||
_provider.AddMessage(timestamp, message);
|
||||
|
||||
var EonaCatMessage = 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);
|
||||
}
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
|
||||
@@ -54,16 +54,21 @@ namespace EonaCat.Logger.Internal
|
||||
|
||||
if (_currentBatch.Count > 0)
|
||||
{
|
||||
bool isBatchWritten = false;
|
||||
try
|
||||
{
|
||||
await WriteMessagesAsync(_currentBatch, _cancellationTokenSource.Token);
|
||||
isBatchWritten = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
_currentBatch.Clear();
|
||||
if (isBatchWritten)
|
||||
{
|
||||
_currentBatch.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
await IntervalAsync(_interval, _cancellationTokenSource.Token);
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace EonaCatLogger.EonaCatCoreLogger.Models
|
||||
public DateTime DateTime { get; set; }
|
||||
public string Message { get; set; }
|
||||
public ELogType LogType { get; set; }
|
||||
public string Origin { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user