@@ -68,7 +68,25 @@ function Parse-PsesLog {
6868 [System.IO.FileShare ]::ReadWrite,
6969 4096 ,
7070 [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+ }
7178
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)
7290 $streamReader = [System.IO.StreamReader ]::new($filestream , [System.Text.Encoding ]::UTF8)
7391
7492 function nextLine () {
@@ -105,8 +123,9 @@ function Parse-PsesLog {
105123 $line = nextLine
106124 }
107125
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 )
110129 }
111130
112131 [string ]$timestampStr = $matches [" ts" ]
@@ -144,30 +163,30 @@ function Parse-PsesLog {
144163 return $result
145164 }
146165
147- if (($Method -eq ' ReadMessage' ) -and
166+ if (($Method -eq ' ReadMessageAsync ' -or $Method -eq ' ReadMessage' ) -and
148167 ($line -match ' ^\s+Received Request '' (?<msg>[^'' ]+)'' with id (?<id>\d+)' )) {
149168 $result.LogMessageType = [PsesLogMessageType ]::Request
150169 $msg = $matches [" msg" ]
151170 $id = $matches [" id" ]
152171 $json = parseLogMessageBodyAsJson
153172 $result.LogMessage = [PsesJsonRpcMessage ]::new($msg , $id , $json.Data , $json.DataSize )
154173 }
155- elseif (($Method -eq ' ReadMessage' ) -and
174+ elseif (($Method -eq ' ReadMessageAsync ' -or $Method -eq ' ReadMessage' ) -and
156175 ($line -match ' ^\s+Received event '' (?<msg>[^'' ]+)'' ' )) {
157176 $result.LogMessageType = [PsesLogMessageType ]::Notification
158177 $msg = $matches [" msg" ]
159178 $json = parseLogMessageBodyAsJson
160179 $result.LogMessage = [PsesNotificationMessage ]::new($msg , [PsesNotificationSource ]::Client, $json.Data , $json.DataSize )
161180 }
162- elseif (($Method -eq ' WriteMessage' ) -and
181+ elseif (($Method -eq ' WriteMessageAsync ' -or $Method -eq ' WriteMessage' ) -and
163182 ($line -match ' ^\s+Writing Response '' (?<msg>[^'' ]+)'' with id (?<id>\d+)' )) {
164183 $result.LogMessageType = [PsesLogMessageType ]::Response
165184 $msg = $matches [" msg" ]
166185 $id = $matches [" id" ]
167186 $json = parseLogMessageBodyAsJson
168187 $result.LogMessage = [PsesJsonRpcMessage ]::new($msg , $id , $json.Data , $json.DataSize )
169188 }
170- elseif (($Method -eq ' WriteMessage' ) -and
189+ elseif (($Method -eq ' WriteMessageAsync ' -or $Method -eq ' WriteMessage' ) -and
171190 ($line -match ' ^\s+Writing event '' (?<msg>[^'' ]+)'' ' )) {
172191 $result.LogMessageType = [PsesLogMessageType ]::Notification
173192 $msg = $matches [" msg" ]
0 commit comments