Logging: Hide trace logging behind flag

This commit is contained in:
Jonathan Jenne 2021-12-14 11:47:45 +01:00
parent 470c899400
commit 44e273137d

View File

@ -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.
''' </summary>
''' <param name="Debug">Adds the Debug rule if true.</param>
Private Sub ReloadConfig(Optional Debug As Boolean = False)
''' <param name="Trace">Adds the Trace rule if true.</param>
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