LoggerContext
This commit is contained in:
parent
3f6579ec27
commit
de64155ebd
@ -1,6 +1,7 @@
|
||||
global using System;
|
||||
global using System.Collections;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Runtime.CompilerServices;
|
||||
global using System.Linq;
|
||||
global using System.Text;
|
||||
global using System.Threading.Tasks;
|
||||
|
||||
@ -5,20 +5,30 @@ namespace DTLib.Logging.New;
|
||||
public static class LoggerExtensions
|
||||
{
|
||||
// replaces same overload in every ILogger instaance
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Log(this ILogger logger, string context, LogSeverity severity, object message)
|
||||
=> logger.Log(context, severity, message, logger.Format);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void LogDebug(this ILogger logger, string context, object message)
|
||||
=> logger.Log(context, LogSeverity.Debug, message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void LogInfo(this ILogger logger, string context, object message)
|
||||
=> logger.Log(context, LogSeverity.Info, message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void LogWarn(this ILogger logger, string context, object message)
|
||||
=> logger.Log(context, LogSeverity.Warn, message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void LogError(this ILogger logger, string context, object message)
|
||||
=> logger.Log(context, LogSeverity.Error, message);
|
||||
|
||||
|
||||
/// uses Ben.Demystifier to serialize exception
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void LogException(this ILogger logger, string context, Exception ex)
|
||||
=> logger.Log(context, LogSeverity.Error, ex.Demystify());
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user