Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit f86c1d0

Browse files
committed
More JSON log parsing
1 parent b1e20f9 commit f86c1d0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/logParser/jsonLogParser.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@ import { LspItem, MsgKind } from '@/logParser/rawLogParser'
22

33
const HEADER_LENGTH = 21
44

5+
const idToRequests = {}
6+
57
export function parseJSONLog(log: string): LspItem {
68
const item = JSON.parse(log.slice(HEADER_LENGTH))
79

10+
if (item.message.id && item.type.startsWith('send')) {
11+
idToRequests[item.message.id] = item
12+
}
13+
814
return {
915
msg: item.message.method,
1016
msgId: item.message.id,
1117
msgKind: convertMsgType(item.type) as MsgKind,
12-
msgType: convertMsgType(item.type),
18+
msgType: item.message.method
19+
? item.message.method
20+
: idToRequests[item.message.id].message.method,
21+
msgLatency: item.type === 'receive-response'
22+
? `${item.timestamp - idToRequests[item.message.id].timestamp}ms`
23+
: null,
1324
arg: item.message,
14-
time: item.timestamp
25+
time: new Date(item.timestamp).toLocaleTimeString(),
1526
}
1627
}
1728

src/store/store.ts

+6
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,10 @@ function itemMatchesKindFilter(item: LspItem, filter: KindFilter) {
227227
store.commit('appendLog', log)
228228
}
229229

230+
window.addEventListener('message', ev => {
231+
store.commit('appendLog', ev.data)
232+
const el = document.querySelector('.msg:last-child')
233+
el.scrollIntoView({ block: 'start', behavior: 'smooth' })
234+
})
235+
230236
export default store

0 commit comments

Comments
 (0)