@@ -12,6 +12,11 @@ function Parse-PsesLog {
12
12
[string ]
13
13
$Path ,
14
14
15
+ # Old log file format <= v1.9.0
16
+ [Parameter ()]
17
+ [switch ]
18
+ $OldLogFormat ,
19
+
15
20
# Hides the progress bar.
16
21
[Parameter ()]
17
22
[switch ]
@@ -22,10 +27,12 @@ function Parse-PsesLog {
22
27
[switch ]
23
28
$SkipRpcMessageBody ,
24
29
30
+ # Emit debug timing info on time to parse each log entry
25
31
[Parameter ()]
26
32
[switch ]
27
33
$DebugTimingInfo ,
28
34
35
+ # Threshold for emitting debug timing info. Default is 100 ms.
29
36
[Parameter ()]
30
37
[int ]
31
38
$DebugTimingThresholdMs = 100
@@ -36,12 +43,22 @@ function Parse-PsesLog {
36
43
$script :currentLineNum = 1
37
44
$script :logEntryIndex = 0
38
45
39
- # Example log entry start:
40
- # 2018-11-24 12:26:58.302 [DIAGNOSTIC] tid:28 in 'ReadMessage' C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs:114:
41
- $logEntryRegex =
42
- [regex ]::new(
43
- ' (?<ts>[^\[]+)\[(?<lev>([^\]]+))\]\s+tid:(?<tid>\d+)\s+in\s+'' (?<meth>\w+)'' \s+(?<file>..[^:]+):(?<line>\d+)' ,
44
- [System.Text.RegularExpressions.RegexOptions ]::Compiled -bor [System.Text.RegularExpressions.RegexOptions ]::IgnoreCase)
46
+ if ($OldLogFormat ) {
47
+ # Example old log entry start
48
+ # 2018-11-15 19:49:06.979 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartLogging', line 160:
49
+ $logEntryRegex =
50
+ [regex ]::new(
51
+ ' ^(?<ts>[^\[]+)\[(?<lev>([^\]]+))\]\s+(?<file>..[^:]+):\s+In method\s+'' (?<meth>\w+)'' ,\s+line\s+(?<line>\d+)' ,
52
+ [System.Text.RegularExpressions.RegexOptions ]::Compiled -bor [System.Text.RegularExpressions.RegexOptions ]::IgnoreCase)
53
+ }
54
+ else {
55
+ # Example new log entry start:
56
+ # 2018-11-24 12:26:58.302 [DIAGNOSTIC] tid:28 in 'ReadMessage' C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs:114:
57
+ $logEntryRegex =
58
+ [regex ]::new(
59
+ ' ^(?<ts>[^\[]+)\[(?<lev>([^\]]+))\]\s+tid:(?<tid>\d+)\s+in\s+'' (?<meth>\w+)'' \s+(?<file>..[^:]+):(?<line>\d+)' ,
60
+ [System.Text.RegularExpressions.RegexOptions ]::Compiled -bor [System.Text.RegularExpressions.RegexOptions ]::IgnoreCase)
61
+ }
45
62
46
63
$filestream =
47
64
[System.IO.FileStream ]::new(
@@ -102,7 +119,7 @@ function Parse-PsesLog {
102
119
103
120
$message = parseMessage $method
104
121
105
- [PsesLogEntry ]::new($script :logEntryIndex , $timestamp , $timestampStr , $logLevel , $threadId , $method ,
122
+ [PsesLogEntry ]::new($script :logEntryIndex , $timestamp , $timestampStr , $logLevel , $threadId , $method ,
106
123
$file , $lineNumber , $message.MessageType , $message.Message )
107
124
108
125
if ($DebugTimingInfo ) {
0 commit comments