fix: 日志异常提取
This commit is contained in:
@@ -40,6 +40,13 @@
|
||||
<span>{{ parseTime(scope.row.create_time) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 错误信息 -->
|
||||
<el-table-column :label="$t('ErrorLog.table.error_message')" min-width="200" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseExceptionMessage(scope.row.exception_detail) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 错误信息提取 -->
|
||||
<el-table-column :label="$t('ErrorLog.table.err_del')" width="150px">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="info(scope.row.log_id)">{{ $t('ErrorLog.table.see_del') }}</el-button>
|
||||
@@ -82,6 +89,55 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 解析异常信息
|
||||
parseExceptionMessage(exceptionDetail) {
|
||||
if (!exceptionDetail) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
try {
|
||||
let exceptionStr = ''
|
||||
|
||||
// 处理不同类型的数据
|
||||
if (typeof exceptionDetail === 'string') {
|
||||
// 尝试 Base64 解码
|
||||
try {
|
||||
exceptionStr = decodeURIComponent(escape(atob(exceptionDetail)))
|
||||
} catch (e) {
|
||||
// 如果不是 Base64,直接使用原字符串
|
||||
exceptionStr = exceptionDetail
|
||||
}
|
||||
} else if (Array.isArray(exceptionDetail)) {
|
||||
// 如果是字节数组,转换为字符串
|
||||
exceptionStr = String.fromCharCode.apply(null, exceptionDetail)
|
||||
} else if (exceptionDetail instanceof Uint8Array) {
|
||||
exceptionStr = new TextDecoder('utf-8').decode(exceptionDetail)
|
||||
} else {
|
||||
return '-'
|
||||
}
|
||||
|
||||
// 匹配 org.nl.common.exception.BadRequestException: 后面的内容
|
||||
const regex = /org\.nl\.common\.exception\.BadRequestException:\s*(.+?)(?:\r?\n|\s+at\s+|$)/
|
||||
const match = exceptionStr.match(regex)
|
||||
|
||||
if (match && match[1]) {
|
||||
return match[1].trim()
|
||||
}
|
||||
|
||||
// 如果没有匹配到,尝试匹配其他异常类型
|
||||
const generalRegex = /Exception:\s*(.+?)(?:\r?\n|\s+at\s+|$)/
|
||||
const generalMatch = exceptionStr.match(generalRegex)
|
||||
|
||||
if (generalMatch && generalMatch[1]) {
|
||||
return generalMatch[1].trim()
|
||||
}
|
||||
|
||||
return '-'
|
||||
} catch (error) {
|
||||
console.error('解析异常信息失败:', error)
|
||||
return '-'
|
||||
}
|
||||
},
|
||||
// 获取异常详情
|
||||
info(log_id) {
|
||||
this.dialog = true
|
||||
|
||||
@@ -8,6 +8,7 @@ export default {
|
||||
'description': 'description',
|
||||
'browser': 'browser',
|
||||
'create_time': 'create time',
|
||||
'error_message': 'error message',
|
||||
'err_del': 'exception details',
|
||||
'see_del': 'view details',
|
||||
'time': 'request time',
|
||||
|
||||
@@ -8,6 +8,7 @@ export default {
|
||||
'description': 'keterangan',
|
||||
'browser': 'peramban',
|
||||
'create_time': 'menciptakan waktu',
|
||||
'error_message': 'pesan kesalahan',
|
||||
'err_del': 'detail pengecualian',
|
||||
'see_del': 'melihat rincian',
|
||||
'time': 'waktu permintaan',
|
||||
|
||||
@@ -8,6 +8,7 @@ export default {
|
||||
'description': '描述',
|
||||
'browser': '浏览器',
|
||||
'create_time': '创建日期',
|
||||
'error_message': '错误信息',
|
||||
'err_del': '异常详情',
|
||||
'see_del': '查看详情',
|
||||
'time': '请求耗时',
|
||||
|
||||
Reference in New Issue
Block a user