Add method to clear internal logs

This commit is contained in:
Jonathan Jenne 2019-07-03 12:24:55 +02:00
parent 507e67309f
commit 90cd63c484
2 changed files with 14 additions and 4 deletions

View File

@ -111,7 +111,7 @@ Public Class LogConfig
Private Const LOG_FORMAT_DEFAULT As String = LOG_FORMAT_BASE & " >> ${message}"
Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}"
Private Const LOG_FORMAT_MEMORY As String = "${message}${newline}${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const LOG_FORMAT_MEMORY As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}${newline}${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const FOLDER_NAME_LOG = "Log"
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
@ -162,13 +162,13 @@ Public Class LogConfig
''' <summary>
''' Returns Logs in Memory as List(Of String) if Debug is enabled
''' Returns nothing if debug is disabled
''' Returns an empty list if debug is disabled
''' </summary>
''' <returns>A list of log messages</returns>
Public ReadOnly Property Logs As List(Of String)
Get
If Debug = False Then
Return Nothing
Return New List(Of String)
End If
Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY)
@ -257,6 +257,14 @@ Public Class LogConfig
Return LogFactory.GetLogger(Of Logger)(ClassName)
End Function
''' <summary>
''' Clears the internal log
''' </summary>
Public Sub ClearLogs()
Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY)
oTarget?.Logs.Clear()
End Sub
''' <summary>
''' Gets the fully qualified name of the class invoking the calling method,
''' including the namespace but Not the assembly.
@ -432,5 +440,7 @@ Public Class LogConfig
Return memoryLog
End Function
#End Region
End Class

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("0.0.1.0")>
<Assembly: AssemblyVersion("0.0.1.1")>
<Assembly: AssemblyFileVersion("1.0.0.0")>