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_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_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_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 FOLDER_NAME_LOG = "Log"
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt" Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
@ -162,13 +162,13 @@ Public Class LogConfig
''' <summary> ''' <summary>
''' Returns Logs in Memory as List(Of String) if Debug is enabled ''' 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> ''' </summary>
''' <returns>A list of log messages</returns> ''' <returns>A list of log messages</returns>
Public ReadOnly Property Logs As List(Of String) Public ReadOnly Property Logs As List(Of String)
Get Get
If Debug = False Then If Debug = False Then
Return Nothing Return New List(Of String)
End If End If
Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY) Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY)
@ -257,6 +257,14 @@ Public Class LogConfig
Return LogFactory.GetLogger(Of Logger)(ClassName) Return LogFactory.GetLogger(Of Logger)(ClassName)
End Function 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> ''' <summary>
''' Gets the fully qualified name of the class invoking the calling method, ''' Gets the fully qualified name of the class invoking the calling method,
''' including the namespace but Not the assembly. ''' including the namespace but Not the assembly.
@ -432,5 +440,7 @@ Public Class LogConfig
Return memoryLog Return memoryLog
End Function End Function
#End Region #End Region
End Class End Class

View File

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