More JSON log parsing
This commit is contained in:
Родитель
b1e20f97f7
Коммит
f86c1d04c3
|
@ -2,16 +2,27 @@ import { LspItem, MsgKind } from '@/logParser/rawLogParser'
|
|||
|
||||
const HEADER_LENGTH = 21
|
||||
|
||||
const idToRequests = {}
|
||||
|
||||
export function parseJSONLog(log: string): LspItem {
|
||||
const item = JSON.parse(log.slice(HEADER_LENGTH))
|
||||
|
||||
if (item.message.id && item.type.startsWith('send')) {
|
||||
idToRequests[item.message.id] = item
|
||||
}
|
||||
|
||||
return {
|
||||
msg: item.message.method,
|
||||
msgId: item.message.id,
|
||||
msgKind: convertMsgType(item.type) as MsgKind,
|
||||
msgType: convertMsgType(item.type),
|
||||
msgType: item.message.method
|
||||
? item.message.method
|
||||
: idToRequests[item.message.id].message.method,
|
||||
msgLatency: item.type === 'receive-response'
|
||||
? `${item.timestamp - idToRequests[item.message.id].timestamp}ms`
|
||||
: null,
|
||||
arg: item.message,
|
||||
time: item.timestamp
|
||||
time: new Date(item.timestamp).toLocaleTimeString(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -227,4 +227,10 @@ function itemMatchesKindFilter(item: LspItem, filter: KindFilter) {
|
|||
store.commit('appendLog', log)
|
||||
}
|
||||
|
||||
window.addEventListener('message', ev => {
|
||||
store.commit('appendLog', ev.data)
|
||||
const el = document.querySelector('.msg:last-child')
|
||||
el.scrollIntoView({ block: 'start', behavior: 'smooth' })
|
||||
})
|
||||
|
||||
export default store
|
||||
|
|
Загрузка…
Ссылка в новой задаче