Version 3.0.338

This commit is contained in:
Anja Müller-Meißner 2022-09-06 16:08:19 +02:00 committed by Anja
parent 573fe77e12
commit 0468955d49
751 changed files with 62747 additions and 60672 deletions

View file

@ -5,43 +5,43 @@ using Serilog.Events;
namespace TINK.Services.Logging
{
public class MemoryStackSink : ILogEventSink
{
private readonly IFormatProvider _formatProvider;
public class MemoryStackSink : ILogEventSink
{
private readonly IFormatProvider _formatProvider;
private static ConcurrentStack<string> _MessageStack = new ConcurrentStack<string>();
private static ConcurrentStack<string> _MessageStack = new ConcurrentStack<string>();
/// <summary>
/// Reads all messages an clears memory stack.
/// </summary>
/// <returns>Array of messages.</returns>
public static string[] PopAllMessages()
{
int countOfMessages = _MessageStack.Count;
if (countOfMessages <= 0)
return new string[0];
/// <summary>
/// Reads all messages an clears memory stack.
/// </summary>
/// <returns>Array of messages.</returns>
public static string[] PopAllMessages()
{
int countOfMessages = _MessageStack.Count;
if (countOfMessages <= 0)
return new string[0];
string[] messages = new string[countOfMessages];
if (_MessageStack.TryPopRange(messages) <= 0)
return new string[0];
string[] messages = new string[countOfMessages];
if (_MessageStack.TryPopRange(messages) <= 0)
return new string[0];
return messages;
}
return messages;
}
/// <summary>
/// Clears the message stack.
/// </summary>
public static void ClearMessages() => _MessageStack.Clear();
/// <summary>
/// Clears the message stack.
/// </summary>
public static void ClearMessages() => _MessageStack.Clear();
public MemoryStackSink(IFormatProvider formatProvider)
{
_formatProvider = formatProvider;
}
public MemoryStackSink(IFormatProvider formatProvider)
{
_formatProvider = formatProvider;
}
public void Emit(LogEvent logEvent)
{
var message = logEvent.RenderMessage(_formatProvider);
_MessageStack.Push(DateTimeOffset.Now.ToString() + " " + message);
}
}
public void Emit(LogEvent logEvent)
{
var message = logEvent.RenderMessage(_formatProvider);
_MessageStack.Push(DateTimeOffset.Now.ToString() + " " + message);
}
}
}

View file

@ -4,13 +4,13 @@ using Serilog.Configuration;
namespace TINK.Services.Logging
{
public static class MemoryStackSinkExtensions
{
public static LoggerConfiguration MemoryQueueSink(
this LoggerSinkConfiguration loggerConfiguration,
IFormatProvider formatProvider = null)
{
return loggerConfiguration.Sink(new MemoryStackSink(formatProvider));
}
}
public static class MemoryStackSinkExtensions
{
public static LoggerConfiguration MemoryQueueSink(
this LoggerSinkConfiguration loggerConfiguration,
IFormatProvider formatProvider = null)
{
return loggerConfiguration.Sink(new MemoryStackSink(formatProvider));
}
}
}