improve logging in profile filter

This commit is contained in:
Jonathan Jenne
2019-10-24 16:34:32 +02:00
parent 8239883b47
commit 660231325c
2 changed files with 40 additions and 17 deletions

View File

@@ -84,6 +84,7 @@ Public Class ProfileFilter
Dim oMatch = oRegex.Match(ClipboardContents)
If oMatch.Success Then
_Logger.Debug("FilterProfilesByClipboardRegex: Clipboard Regex Matched: {0}", ClipboardContents)
_Logger.Info("Profile {0} matched!", oProfile.Name)
oFilteredProfiles.Add(oProfile)
oProfile.IsMatched = True
@@ -104,10 +105,6 @@ Public Class ProfileFilter
For Each oProfile In Profiles
Dim oGuid = oProfile.Guid
If oProfile.IsMatched = False Then
Continue For
End If
Dim oProcesses As New List(Of ProcessData)
For Each oProcessDef As ProcessData In oProfile.Processes
If oProcessDef.PROFILE_ID <> oGuid Then
@@ -121,11 +118,13 @@ Public Class ProfileFilter
oParent.Nodes.Add(oNode)
End If
_Logger.Debug($"FilterProfilesByProcess: Checking Profile: {oProfile.Name} ...")
_Logger.Debug($"FilterProfilesByProcess: Checking Profile: {oProfile.Name}")
If oIsMatch Then
_Logger.Debug($"Yes...Processname Matched: {oProcessDef.ProcessName}")
'TODO: Add Debug Data
_Logger.Debug($"Processname Matched: {oProcessDef.ProcessName}")
oFilteredProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
oProfile.MatchedProcessID = oProcessDef.Guid
oProcessDef.IsMatched = True
oProcesses.Add(oProcessDef)
@@ -151,9 +150,16 @@ Public Class ProfileFilter
For Each oProfile As ProfileData In Profiles
_Logger.Debug("Checking WindowDefinition for profile: {0}...", oProfile.Name)
If oProfile.IsMatched = False Then Continue For
Dim oWindows As New List(Of WindowData)
' If Profile has no windows at all, it automatically matches
If oProfile.Windows.Count = 0 Then
oProfile.IsMatched = True
oProfiles.Add(oProfile)
Continue For
End If
For Each oWindowDef As WindowData In oProfile.Windows
If oWindowDef.WindowProcessID <> oProfile.MatchedProcessID Then Continue For
Try
@@ -186,10 +192,13 @@ Public Class ProfileFilter
End Try
Next
' If Profile has windows that matched, the profile matches
If oWindows.Count > 0 Then
oProfile.Windows = oWindows
oProfile.IsMatched = True
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
End If
Next
@@ -201,8 +210,7 @@ Public Class ProfileFilter
Dim oWindow As New Window(_LogConfig)
For Each oProfile In Profiles
If oProfile.IsMatched = False Then Continue For
' If Profile has no controls at all, it automatically matches
If oProfile.Controls.Count = 0 Then
oFilteredProfiles.Add(oProfile)
Continue For
@@ -246,13 +254,15 @@ Public Class ProfileFilter
End If
Next
' If Profile has controls that matched, the profile matches
If oControls.Count > 0 Then
oProfile.Controls = oControls
oFilteredProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
End If
Next
Return oFilteredProfiles
End Function
@@ -320,10 +330,14 @@ Public Class ProfileFilter
End Try
Next
If oResultData > 0 Or oResultDocs > 0 Then
oProfile.CountData = oResultData
oProfile.CountDocs = oResultDocs
oProfile.CountData = oResultData
oProfile.CountDocs = oResultDocs
Next
For Each oProfile In Profiles
If oProfile.CountData > 0 Or oProfile.CountDocs > 0 Then
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
End If
Next
@@ -368,6 +382,8 @@ Public Class ProfileFilter
If oWindows.Count > 0 Then
oProfile.Windows = oWindows
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
End If
Next