removed other projects
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Serilog.Configuration;
|
||||
using LogViewer.Core;
|
||||
using Serilog.Sinks.LogView.Core.Logging;
|
||||
|
||||
namespace Serilog.Sinks.LogView.Core.Extensions;
|
||||
|
||||
public static class DataStoreLoggerSinkExtensions
|
||||
{
|
||||
public static LoggerConfiguration DataStoreLoggerSink
|
||||
(
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
Func<ILogDataStore> dataStoreProvider,
|
||||
Action<DataStoreLoggerConfiguration>? configuration = null,
|
||||
IFormatProvider formatProvider = null!
|
||||
)
|
||||
=> loggerConfiguration.Sink(new DataStoreLoggerSink(dataStoreProvider, GetConfig(configuration), formatProvider));
|
||||
|
||||
private static Func<DataStoreLoggerConfiguration> GetConfig(Action<DataStoreLoggerConfiguration>? configuration)
|
||||
{
|
||||
// convert from Action to Func delegate to pass data
|
||||
DataStoreLoggerConfiguration data = new();
|
||||
configuration?.Invoke(data);
|
||||
return () => data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
namespace Microsoft.Extensions.Logging;
|
||||
|
||||
public static class LoggerExtensions
|
||||
{
|
||||
public static void Emit(this ILogger logger, EventId eventId,
|
||||
LogLevel logLevel, string message, Exception? exception = null, params object?[] args)
|
||||
{
|
||||
if (logger is null)
|
||||
return;
|
||||
|
||||
//if (!logger.IsEnabled(logLevel))
|
||||
// return;
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
case LogLevel.Trace:
|
||||
logger.LogTrace(eventId, message, args);
|
||||
break;
|
||||
|
||||
case LogLevel.Debug:
|
||||
logger.LogDebug(eventId, message, args);
|
||||
break;
|
||||
|
||||
case LogLevel.Information:
|
||||
logger.LogInformation(eventId, message, args);
|
||||
break;
|
||||
|
||||
case LogLevel.Warning:
|
||||
logger.LogWarning(eventId, exception, message, args);
|
||||
break;
|
||||
|
||||
case LogLevel.Error:
|
||||
logger.LogError(eventId, exception, message, args);
|
||||
break;
|
||||
|
||||
case LogLevel.Critical:
|
||||
logger.LogCritical(eventId, exception, message, args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestPattern(this ILogger logger, EventId eventId)
|
||||
{
|
||||
Exception exception = new InvalidDataException("Test Error Message");
|
||||
|
||||
#pragma warning disable CA1848 // Use the LoggerMessage delegates
|
||||
logger.Emit(eventId, LogLevel.Trace, "Trace Test Pattern");
|
||||
logger.Emit(eventId, LogLevel.Debug, "Debug Test Pattern");
|
||||
logger.Emit(eventId, LogLevel.Information, "Information Test Pattern");
|
||||
logger.Emit(eventId, LogLevel.Warning, "Warning Test Pattern");
|
||||
logger.Emit(eventId, LogLevel.Error, "Error Test Pattern", exception);
|
||||
logger.Emit(eventId, LogLevel.Critical, "Critical Test Pattern", exception);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user