Преглед изворни кода

Add a method to manually refresh the log configuration

Lucas Trzesniewski пре 3 година
родитељ
комит
aadd298d1b
2 измењених фајлова са 6 додато и 3 уклоњено
  1. 1 1
      src/Abc.Zebus/Core/BusMessageLogger.cs
  2. 5 2
      src/Abc.Zebus/ZebusLogManager.cs

+ 1 - 1
src/Abc.Zebus/Core/BusMessageLogger.cs

@@ -27,7 +27,7 @@ namespace Abc.Zebus.Core
             _logger = ZebusLogManager.GetLogger(loggerFullName);
             _logger = ZebusLogManager.GetLogger(loggerFullName);
 
 
             // Instances of BusMessageLogger are static, no need to unsubscribe from this event
             // Instances of BusMessageLogger are static, no need to unsubscribe from this event
-            ZebusLogManager.LoggerFactoryChanged += UpdateLogConfig;
+            ZebusLogManager.ConfigurationUpdated += UpdateLogConfig;
 
 
             UpdateLogConfig();
             UpdateLogConfig();
 
 

+ 5 - 2
src/Abc.Zebus/ZebusLogManager.cs

@@ -20,11 +20,11 @@ namespace Abc.Zebus
                     return;
                     return;
 
 
                 _loggerFactory = value;
                 _loggerFactory = value;
-                LoggerFactoryChanged?.Invoke();
+                RefreshConfiguration();
             }
             }
         }
         }
 
 
-        public static event Action? LoggerFactoryChanged;
+        public static event Action? ConfigurationUpdated;
 
 
         public static ILogger GetLogger(string name)
         public static ILogger GetLogger(string name)
             => new ForwardingLogger(name);
             => new ForwardingLogger(name);
@@ -32,6 +32,9 @@ namespace Abc.Zebus
         public static ILogger GetLogger(Type type)
         public static ILogger GetLogger(Type type)
             => GetLogger(type.FullName!);
             => GetLogger(type.FullName!);
 
 
+        public static void RefreshConfiguration()
+            => ConfigurationUpdated?.Invoke();
+
         private class ForwardingLogger : ILogger
         private class ForwardingLogger : ILogger
         {
         {
             private readonly string _name;
             private readonly string _name;