diff --git a/DTLib.Logging/DTLib.Logging.csproj b/DTLib.Logging/DTLib.Logging.csproj index 9750366..7768884 100644 --- a/DTLib.Logging/DTLib.Logging.csproj +++ b/DTLib.Logging/DTLib.Logging.csproj @@ -2,7 +2,7 @@ DTLib.Logging - 1.0.3 + 1.0.4 Timerix Loggers with dependency injection GIT @@ -30,6 +30,6 @@ - + diff --git a/DTLib.Logging/LoggerContext.cs b/DTLib.Logging/Loggers/ContextLogger.cs similarity index 57% rename from DTLib.Logging/LoggerContext.cs rename to DTLib.Logging/Loggers/ContextLogger.cs index 6d8c59d..5b2e3ae 100644 --- a/DTLib.Logging/LoggerContext.cs +++ b/DTLib.Logging/Loggers/ContextLogger.cs @@ -1,12 +1,12 @@ namespace DTLib.Logging.New; /// wrapper around ILogger and LoggerExtensions that stores context -public class LoggerContext +public class ContextLogger : ILogger { public ILogger Logger; public readonly string Context; - public LoggerContext(ILogger logger, string context) + public ContextLogger(ILogger logger, string context) { Logger = logger; Context = context; @@ -41,4 +41,41 @@ public class LoggerContext [MethodImpl(MethodImplOptions.AggressiveInlining)] public void LogError(Exception ex) => Logger.LogError(Context, ex); + + public void Dispose() + { + Logger.Dispose(); + } + + public ILogFormat Format => Logger.Format; + + public bool DebugLogEnabled + { + get => Logger.DebugLogEnabled; + set => Logger.DebugLogEnabled = value; + } + + public bool InfoLogEnabled + { + get => Logger.InfoLogEnabled; + set => Logger.InfoLogEnabled = value; + } + + public bool WarnLogEnabled + { + get => Logger.WarnLogEnabled; + set => Logger.WarnLogEnabled = value; + } + + public bool ErrorLogenabled + { + get => Logger.ErrorLogenabled; + set => Logger.ErrorLogenabled = value; + } + + /// Appends subContext to Context + public void Log(string subContext, LogSeverity severity, object message, ILogFormat format) + { + Logger.Log($"{Context}/{subContext}", severity, message, format); + } } \ No newline at end of file