-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Right now I made a fork without the dependency Microsoft.Extensions.Logging.Abstractions https://github.com/pairbit/IT.Redis
The fact is that Microsoft.Extensions.Logging.LoggerExtensions are very bad, they are prohibited from being used in our projects.
Please create your own IRedisLogger interface without params object[]. Also replace the ILoggerFactory type with the Func<Type,IRedisLogger> delegate.
namespace StackExchange.Redis;
public interface IRedisLogger
{
void Log(int level, Exception? exception, string? message);
}
and
namespace StackExchange.Redis.Configuration;
public class DefaultOptionsProvider
{
public virtual Func<Type, IRedisLogger>? LoggerFactory => null;
}
and internal extension for logging
internal enum Level
{
Trace,
Debug,
Information,
Warning,
Error,
Critical,
None
}
internal static class IRedisLoggerExtensions
{
public static void LogInformation(this IRedisLogger logger, string? message)
=> logger.Log((int)Level.Information, null, message);
public static void LogTrace(this IRedisLogger logger, string? message)
=> logger.Log((int)Level.Trace, null, message);
public static void LogInformation(this IRedisLogger logger, Exception? exception, string? message)
=> logger.Log((int)Level.Information, exception, message);
public static void LogError(this IRedisLogger logger, Exception? exception, string? message)
=> logger.Log((int)Level.Error, exception, message);
}
internal static class LoggerFactoryExtensions
{
public static ILogger CreateLogger<T>(this Func<Type, IRedisLogger> factory)
=> factory(typeof(T));
}
I see that you do not use logging with params object[], but I primarily liked your library for its small number of dependencies.
Please do not close the ticket immediately. Consider my proposal. Thank you
neon-sunset, epeshk, t-smirnov, hexawyz and Meir017
Metadata
Metadata
Assignees
Labels
No labels