-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Robin Appelman <robin@icewind.nl>
- Loading branch information
1 parent
61568e6
commit 1cabf22
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<div> | ||
<div> | ||
<button @click="expanded = !expanded"> | ||
Toggle Backtrace | ||
</button> | ||
</div> | ||
<div v-if="expanded"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th class="line"> | ||
Line | ||
</th> | ||
<th class="method"> | ||
Method | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(row, key) in trace" :key="key"> | ||
<td class="line"> | ||
{{ row.line }} | ||
</td> | ||
<td class="method"> | ||
{{ row.call }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'Backtrace', | ||
props: { | ||
backtrace: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
data: () => { | ||
return { expanded: false } | ||
}, | ||
computed: { | ||
filePrefix() { | ||
const files = this.backtrace.map(line => line.file || '') | ||
if (!files[0] || files.length === 1) { | ||
return files[0] || '' | ||
} | ||
let i = 0 | ||
while (files[0][i] && files.every(w => w[i] === files[0][i])) { | ||
i++ | ||
} | ||
return files[0].substr(0, i) | ||
}, | ||
trace() { | ||
const prefixLength = this.filePrefix.length | ||
return this.backtrace.map(line => { | ||
return { | ||
line: line.file ? (line.file.substr(prefixLength) + ' ' + line.line) : '--', | ||
call: line.class ? (line.class + line.type + line.function) : line.function, | ||
} | ||
}) | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
th { | ||
font-weight: bold; | ||
} | ||
td.line { | ||
padding-right: 2em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters