@@ -68,7 +68,25 @@ function Parse-PsesLog {
68
68
[System.IO.FileShare ]::ReadWrite,
69
69
4096 ,
70
70
[System.IO.FileOptions ]::SequentialScan)
71
+ $streamReader = [System.IO.StreamReader ]::new($filestream , [System.Text.Encoding ]::UTF8)
72
+
73
+ # Count number of lines so we can provide % progress while parsing
74
+ $numLines = 0
75
+ while ($null -ne $streamReader.ReadLine ()) {
76
+ $numLines ++
77
+ }
71
78
79
+ # Recreate the stream & reader. Tried seeking to 0 on the stream and having the
80
+ # reader discard buffered data but still wound up with in an invalid $log[0] entry.
81
+ $streamReader.Dispose ()
82
+ $filestream =
83
+ [System.IO.FileStream ]::new(
84
+ $Path ,
85
+ [System.IO.FileMode ]:: Open,
86
+ [System.IO.FileAccess ]::Read,
87
+ [System.IO.FileShare ]::ReadWrite,
88
+ 4096 ,
89
+ [System.IO.FileOptions ]::SequentialScan)
72
90
$streamReader = [System.IO.StreamReader ]::new($filestream , [System.Text.Encoding ]::UTF8)
73
91
74
92
function nextLine () {
@@ -105,8 +123,9 @@ function Parse-PsesLog {
105
123
$line = nextLine
106
124
}
107
125
108
- if (! $HideProgress -and ($script :logEntryIndex % 50 -eq 0 )) {
109
- Write-Progress " Processing log entry ${ script:logEntryIndex } on line: ${ script:currentLineNum } "
126
+ if (! $HideProgress -and ($script :logEntryIndex % 100 -eq 0 )) {
127
+ Write-Progress " Processing log entry ${ script:logEntryIndex } on line: ${ script:currentLineNum } " `
128
+ - PercentComplete (100 * $script :currentLineNum / $numLines )
110
129
}
111
130
112
131
[string ]$timestampStr = $matches [" ts" ]
@@ -144,30 +163,30 @@ function Parse-PsesLog {
144
163
return $result
145
164
}
146
165
147
- if (($Method -eq ' ReadMessage' ) -and
166
+ if (($Method -eq ' ReadMessageAsync ' -or $Method -eq ' ReadMessage' ) -and
148
167
($line -match ' ^\s+Received Request '' (?<msg>[^'' ]+)'' with id (?<id>\d+)' )) {
149
168
$result.LogMessageType = [PsesLogMessageType ]::Request
150
169
$msg = $matches [" msg" ]
151
170
$id = $matches [" id" ]
152
171
$json = parseLogMessageBodyAsJson
153
172
$result.LogMessage = [PsesJsonRpcMessage ]::new($msg , $id , $json.Data , $json.DataSize )
154
173
}
155
- elseif (($Method -eq ' ReadMessage' ) -and
174
+ elseif (($Method -eq ' ReadMessageAsync ' -or $Method -eq ' ReadMessage' ) -and
156
175
($line -match ' ^\s+Received event '' (?<msg>[^'' ]+)'' ' )) {
157
176
$result.LogMessageType = [PsesLogMessageType ]::Notification
158
177
$msg = $matches [" msg" ]
159
178
$json = parseLogMessageBodyAsJson
160
179
$result.LogMessage = [PsesNotificationMessage ]::new($msg , [PsesNotificationSource ]::Client, $json.Data , $json.DataSize )
161
180
}
162
- elseif (($Method -eq ' WriteMessage' ) -and
181
+ elseif (($Method -eq ' WriteMessageAsync ' -or $Method -eq ' WriteMessage' ) -and
163
182
($line -match ' ^\s+Writing Response '' (?<msg>[^'' ]+)'' with id (?<id>\d+)' )) {
164
183
$result.LogMessageType = [PsesLogMessageType ]::Response
165
184
$msg = $matches [" msg" ]
166
185
$id = $matches [" id" ]
167
186
$json = parseLogMessageBodyAsJson
168
187
$result.LogMessage = [PsesJsonRpcMessage ]::new($msg , $id , $json.Data , $json.DataSize )
169
188
}
170
- elseif (($Method -eq ' WriteMessage' ) -and
189
+ elseif (($Method -eq ' WriteMessageAsync ' -or $Method -eq ' WriteMessage' ) -and
171
190
($line -match ' ^\s+Writing event '' (?<msg>[^'' ]+)'' ' )) {
172
191
$result.LogMessageType = [PsesLogMessageType ]::Notification
173
192
$msg = $matches [" msg" ]
0 commit comments