breaking change in ContextLogger constructor
This commit is contained in:
parent
f141f4a599
commit
021e9d1b65
@ -17,7 +17,7 @@ public static class DTLibInternalLogging
|
||||
|
||||
public static void SetLogger(ILogger logger)
|
||||
{
|
||||
_loggerContext = new ContextLogger(logger, "DTLib");
|
||||
_loggerContext = new ContextLogger("DTLib",logger);
|
||||
PublicLog.LogEvent+=LogHandler;
|
||||
}
|
||||
|
||||
|
||||
@ -6,12 +6,18 @@ public class ContextLogger : ILogger
|
||||
public ILogger ParentLogger;
|
||||
public readonly string Context;
|
||||
|
||||
public ContextLogger(ILogger parentLogger, string context)
|
||||
public ContextLogger(string context,ILogger parentLogger)
|
||||
{
|
||||
ParentLogger = parentLogger;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
/// Appends subContext to Context
|
||||
public void Log(string subContext, LogSeverity severity, object message, ILogFormat format)
|
||||
{
|
||||
ParentLogger.Log($"{Context}/{subContext}", severity, message, format);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Log(LogSeverity severity, object message)
|
||||
=> ParentLogger.Log(Context, severity, message);
|
||||
@ -42,10 +48,7 @@ public class ContextLogger : ILogger
|
||||
public void LogError(Exception ex)
|
||||
=> ParentLogger.LogError(Context, ex);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ParentLogger.Dispose();
|
||||
}
|
||||
public void Dispose() => ParentLogger.Dispose();
|
||||
|
||||
public ILogFormat Format => ParentLogger.Format;
|
||||
|
||||
@ -72,10 +75,4 @@ public class ContextLogger : ILogger
|
||||
get => ParentLogger.ErrorLogEnabled;
|
||||
set => ParentLogger.ErrorLogEnabled = value;
|
||||
}
|
||||
|
||||
/// Appends subContext to Context
|
||||
public void Log(string subContext, LogSeverity severity, object message, ILogFormat format)
|
||||
{
|
||||
ParentLogger.Log($"{Context}/{subContext}", severity, message, format);
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,7 @@ public static class Program
|
||||
System.Console.InputEncoding = Encoding.UTF8;
|
||||
Logger=new CompositeLogger(new ConsoleLogger(),
|
||||
new FileLogger("logs", "DTLib.Tests"));
|
||||
var mainContext = new ContextLogger(Logger, "Main");
|
||||
var mainContext = new ContextLogger("Main", Logger);
|
||||
DTLibInternalLogging.SetLogger(Logger);
|
||||
|
||||
try
|
||||
|
||||
Loading…
Reference in New Issue
Block a user