加入日志异常检测

This commit is contained in:
marvzhang
2020-04-18 18:42:46 +08:00
parent 55cf81a6a0
commit 3633331879
10 changed files with 110 additions and 32 deletions

View File

@@ -13,6 +13,10 @@
</template>
<script>
import {
mapGetters
} from 'vuex'
export default {
name: 'LogItem',
props: {
@@ -45,10 +49,19 @@ export default {
},
data () {
return {
errorRegex: this.$utils.log.errorRegex
}
},
computed: {
...mapGetters('user', [
'userInfo'
]),
errorRegex () {
if (!this.userInfo.setting.error_regex_pattern) {
return this.$utils.log.errorRegex
}
console.log(this.userInfo.setting.error_regex_pattern)
return new RegExp(this.userInfo.setting.error_regex_pattern, 'i')
},
dataHtml () {
let html = this.data.replace(this.errorRegex, ' <span style="font-weight: bolder; text-decoration: underline">$1</span> ')
if (!this.searchString) return html

View File

@@ -8,18 +8,19 @@
style="margin-right: 10px"
>
</el-switch>
<el-switch
v-model="isLogAutoFetch"
:inactive-text="$t('Auto-Refresh')"
style="margin-right: 10px"
>
</el-switch>
<!-- <el-switch-->
<!-- v-model="isLogAutoFetch"-->
<!-- :inactive-text="$t('Auto-Refresh')"-->
<!-- style="margin-right: 10px"-->
<!-- >-->
<!-- </el-switch>-->
<el-input
v-model="logKeyword"
size="small"
suffix-icon="el-icon-search"
:placeholder="$t('Search Log')"
style="width: 240px; margin-right: 10px"
clearable
/>
<el-button
size="small"
@@ -138,11 +139,11 @@ export default {
'taskForm',
'taskLogTotal',
'logKeyword',
'isLogFetchLoading'
'isLogFetchLoading',
'errorLogData'
]),
...mapGetters('task', [
'logData',
'errorLogData'
'logData'
]),
currentLogIndex: {
get () {
@@ -257,9 +258,6 @@ export default {
},
toBottom () {
this.$el.querySelector('.log-view').scrollTo({ top: 99999999 })
},
onAutoScroll () {
},
toggleErrors () {
this.isErrorsCollapsed = !this.isErrorsCollapsed
@@ -268,15 +266,14 @@ export default {
this.isErrorCollapsing = false
}, 300)
},
onClickError (item) {
this.currentLogIndex = item.index
this.isLogAutoScroll = false
const handle = setInterval(() => {
this.isLogAutoScroll = false
}, 10)
setTimeout(() => {
clearInterval(handle)
}, 500)
async onClickError (item) {
const page = Math.ceil(item.seq / this.taskLogPageSize)
this.$store.commit('task/SET_LOG_KEYWORD', '')
this.$store.commit('task/SET_TASK_LOG_PAGE', page)
this.$store.commit('task/SET_IS_LOG_AUTO_SCROLL', false)
this.$store.commit('task/SET_ACTIVE_ERROR_LOG_ITEM', item)
this.$emit('search')
this.$st.sendEv('任务详情', '日志', '点击错误日志')
},
onSearchLog () {
this.$emit('search')