@@ -11,7 +11,7 @@ Public Class Logger
1111 Private ReadOnly LogFile As New Microsoft.VisualBasic.Logging.FileLogTraceListener()
1212 Private ReadOnly TEventCache As New TraceEventCache()
1313 ' Enable writing to a log file.
14- Public WriteLogValue As Boolean
14+ Public WriteToFile As Boolean
1515 Public LogLevelValue As LogLvl
1616 Private L_CurrentLogData As String
1717 Private LastEventsList As New List( Of Object )
@@ -33,7 +33,7 @@ Public Class Logger
3333 End Get
3434 End Property
3535 Public Sub New ( ByVal WriteLog As Boolean , ByVal LogLevel As LogLvl)
36- Me .WriteLogValue = WriteLog
36+ Me .WriteToFile = WriteLog
3737 Me .LogLevelValue = LogLevel
3838 Me .LogFile.TraceOutputOptions = TraceOptions.DateTime Or TraceOptions.ProcessId
3939 Me .LogFile.Append = True
@@ -43,16 +43,16 @@ Public Class Logger
4343 Me .LogFile.Location = Microsoft.VisualBasic.Logging.LogFileLocation.Custom
4444 Me .LogFile.CustomLocation = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\WinNUT-Client"
4545 Me .LastEventsList.Capacity = 50
46- WinNUT_Globals.LogFilePath = Me .LogFile.FullLogFileName
46+ ' WinNUT_Globals.LogFilePath = Me.LogFile.FullLogFileName
4747 End Sub
4848
4949 Public Property WriteLog() As Boolean
5050 Get
51- Return Me .WriteLogValue
51+ Return Me .WriteToFile
5252 End Get
5353 Set ( ByVal Value As Boolean )
54- Me .WriteLogValue = Value
55- If Not Me .WriteLogValue Then
54+ Me .WriteToFile = Value
55+ If Not Me .WriteToFile Then
5656 LogFile.Dispose()
5757 End If
5858 End Set
@@ -67,18 +67,30 @@ Public Class Logger
6767 End Set
6868 End Property
6969
70+ ''' <summary>
71+ ''' Insert an event into the <see cref="LastEventsList" /> for report generating, write a line to the
72+ ''' <see cref="LogFile"/> if the event is as or more important than the <see cref="LogLevel"/>, and notify any
73+ ''' listeners if <paramref name="LogToDisplay"/> is specified.
74+ ''' </summary>
75+ ''' <param name="message">The raw information that needs to be recorded.</param>
76+ ''' <param name="LvlError">How important the information is.</param>
77+ ''' <param name="sender"></param>
78+ ''' <param name="LogToDisplay">A user-friendly, translated string to be shown.</param>
7079 Public Sub LogTracing( ByVal message As String , ByVal LvlError As Int16, sender As Object , Optional ByVal LogToDisplay As String = Nothing )
7180 Dim Pid = TEventCache.ProcessId
7281 Dim SenderName = sender.GetType.Name
7382 Dim EventTime = Now.ToLocalTime
7483 Dim FinalMsg = EventTime & " Pid: " & Pid & " " & SenderName & " : " & message
7584
7685 'Update LogFilePath to make sure it's still the correct path
77- WinNUT_Globals.LogFilePath = Me .LogFile.FullLogFileName
86+ ' gbakeman 31/7/2022: Disabling since the LogFilePath should never change throughout the lifetime of this
87+ ' object, unless proper initialization has occured.
88+
89+ ' WinNUT_Globals.LogFilePath = Me.LogFile.FullLogFileName
7890
7991 ' Always write log messages to the attached debug messages window.
8092# If DEBUG Then
81- Debug.WriteLine(FinalMsg)
93+ Debug.WriteLine(FinalMsg)
8294# End If
8395
8496 'Create Event in EventList in case of crash for generate Report
@@ -88,7 +100,7 @@ Public Class Logger
88100
89101 Me .LastEventsList.Add(FinalMsg)
90102
91- If Me .WriteLogValue AndAlso Me .LogLevel >= LvlError Then
103+ If Me .WriteToFile AndAlso Me .LogLevel >= LvlError Then
92104 LogFile.WriteLine(FinalMsg)
93105 End If
94106 'If LvlError = LogLvl.LOG_NOTICE Then
0 commit comments