From 90cd63c484271c063c221ec22ed04764ef658bc1 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 3 Jul 2019 12:24:55 +0200 Subject: [PATCH] Add method to clear internal logs --- Modules.Logging/LogConfig.vb | 16 +++++++++++++--- Modules.Logging/My Project/AssemblyInfo.vb | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb index 13dc0281..c76847f3 100644 --- a/Modules.Logging/LogConfig.vb +++ b/Modules.Logging/LogConfig.vb @@ -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 ''' ''' 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 ''' ''' A list of log messages 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 + ''' + ''' Clears the internal log + ''' + Public Sub ClearLogs() + Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY) + oTarget?.Logs.Clear() + End Sub + ''' ''' 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 diff --git a/Modules.Logging/My Project/AssemblyInfo.vb b/Modules.Logging/My Project/AssemblyInfo.vb index 89147117..3f292b18 100644 --- a/Modules.Logging/My Project/AssemblyInfo.vb +++ b/Modules.Logging/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - +