From 44e273137d9448d010d55c256012eebb690236e8 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 14 Dec 2021 11:47:45 +0100 Subject: [PATCH] Logging: Hide trace logging behind flag --- Modules.Logging/LogConfig.vb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb index 081ffac1..73dc2824 100644 --- a/Modules.Logging/LogConfig.vb +++ b/Modules.Logging/LogConfig.vb @@ -101,6 +101,7 @@ Public Class LogConfig Private _config As LoggingConfiguration Private _isDebug As Boolean = False + Private _isTrace As Boolean = False #End Region #Region "Public Properties" @@ -139,7 +140,17 @@ Public Class LogConfig End Get Set(isDebug As Boolean) _isDebug = isDebug - ReloadConfig(isDebug) + ReloadConfig(isDebug, _isTrace) + End Set + End Property + + Public Property Trace As Boolean + Get + Return _isTrace + End Get + Set(isTrace As Boolean) + _isTrace = isTrace + ReloadConfig(_isDebug, isTrace) End Set End Property @@ -467,7 +478,8 @@ Public Class LogConfig ''' Reconfigures and re-adds all loggers, optionally adding the debug rule. ''' ''' Adds the Debug rule if true. - Private Sub ReloadConfig(Optional Debug As Boolean = False) + ''' Adds the Trace rule if true. + Private Sub ReloadConfig(Optional Debug As Boolean = False, Optional Trace As Boolean = False) ' Clear Logging Rules _config.LoggingRules.Clear() @@ -476,11 +488,14 @@ Public Class LogConfig ' Add debug rule, if configured If Debug Then - _config.AddRuleForAllLevels(TARGET_TRACE) _config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_DEBUG) _config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_MEMORY) End If + If Trace Then + _config.AddRuleForAllLevels(TARGET_TRACE) + End If + ' Reload all running loggers LogFactory.ReconfigExistingLoggers() End Sub