ContextLogger.Logger->ParentLogger
This commit is contained in:
parent
61d062673c
commit
516462f5d7
@ -3,79 +3,79 @@ namespace DTLib.Logging.New;
|
|||||||
/// wrapper around ILogger and LoggerExtensions that stores context
|
/// wrapper around ILogger and LoggerExtensions that stores context
|
||||||
public class ContextLogger : ILogger
|
public class ContextLogger : ILogger
|
||||||
{
|
{
|
||||||
public ILogger Logger;
|
public ILogger ParentLogger;
|
||||||
public readonly string Context;
|
public readonly string Context;
|
||||||
|
|
||||||
public ContextLogger(ILogger logger, string context)
|
public ContextLogger(ILogger parentLogger, string context)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
ParentLogger = parentLogger;
|
||||||
Context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Log(LogSeverity severity, object message)
|
public void Log(LogSeverity severity, object message)
|
||||||
=> Logger.Log(Context, severity, message);
|
=> ParentLogger.Log(Context, severity, message);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogDebug(object message)
|
public void LogDebug(object message)
|
||||||
=> Logger.LogDebug(Context, message);
|
=> ParentLogger.LogDebug(Context, message);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogInfo(object message)
|
public void LogInfo(object message)
|
||||||
=> Logger.LogInfo(Context, message);
|
=> ParentLogger.LogInfo(Context, message);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogWarn(object message)
|
public void LogWarn(object message)
|
||||||
=> Logger.LogWarn(Context, message);
|
=> ParentLogger.LogWarn(Context, message);
|
||||||
|
|
||||||
/// uses Ben.Demystifier to serialize exception
|
/// uses Ben.Demystifier to serialize exception
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogWarn(Exception ex)
|
public void LogWarn(Exception ex)
|
||||||
=> Logger.LogWarn(Context, ex);
|
=> ParentLogger.LogWarn(Context, ex);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogError(object message)
|
public void LogError(object message)
|
||||||
=> Logger.LogError(Context, message);
|
=> ParentLogger.LogError(Context, message);
|
||||||
|
|
||||||
/// uses Ben.Demystifier to serialize exception
|
/// uses Ben.Demystifier to serialize exception
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogError(Exception ex)
|
public void LogError(Exception ex)
|
||||||
=> Logger.LogError(Context, ex);
|
=> ParentLogger.LogError(Context, ex);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Logger.Dispose();
|
ParentLogger.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILogFormat Format => Logger.Format;
|
public ILogFormat Format => ParentLogger.Format;
|
||||||
|
|
||||||
public bool DebugLogEnabled
|
public bool DebugLogEnabled
|
||||||
{
|
{
|
||||||
get => Logger.DebugLogEnabled;
|
get => ParentLogger.DebugLogEnabled;
|
||||||
set => Logger.DebugLogEnabled = value;
|
set => ParentLogger.DebugLogEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InfoLogEnabled
|
public bool InfoLogEnabled
|
||||||
{
|
{
|
||||||
get => Logger.InfoLogEnabled;
|
get => ParentLogger.InfoLogEnabled;
|
||||||
set => Logger.InfoLogEnabled = value;
|
set => ParentLogger.InfoLogEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool WarnLogEnabled
|
public bool WarnLogEnabled
|
||||||
{
|
{
|
||||||
get => Logger.WarnLogEnabled;
|
get => ParentLogger.WarnLogEnabled;
|
||||||
set => Logger.WarnLogEnabled = value;
|
set => ParentLogger.WarnLogEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ErrorLogenabled
|
public bool ErrorLogenabled
|
||||||
{
|
{
|
||||||
get => Logger.ErrorLogenabled;
|
get => ParentLogger.ErrorLogenabled;
|
||||||
set => Logger.ErrorLogenabled = value;
|
set => ParentLogger.ErrorLogenabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Appends subContext to Context
|
/// Appends subContext to Context
|
||||||
public void Log(string subContext, LogSeverity severity, object message, ILogFormat format)
|
public void Log(string subContext, LogSeverity severity, object message, ILogFormat format)
|
||||||
{
|
{
|
||||||
Logger.Log($"{Context}/{subContext}", severity, message, format);
|
ParentLogger.Log($"{Context}/{subContext}", severity, message, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user