blob: b22581b5a4a264a509d4e8100e5ce2cd1474a161 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import { LogLevel } from '@shared/models/server/log-level.type'
import omit from 'lodash-es/omit'
export class LogRow {
date: Date
localeDate: string
level: LogLevel
message: string
meta: string
by: string
domain: string
action: string
constructor (row: any) {
this.date = new Date(row.timestamp)
this.localeDate = this.date.toLocaleString()
this.level = row.level
this.message = row.message
const metaObj = omit(row, 'timestamp', 'level', 'message', 'label')
if (Object.keys(metaObj).length !== 0) this.meta = JSON.stringify(metaObj, undefined, 2)
if (row.level === 'audit') {
try {
const message = JSON.parse(row.message)
this.by = message.user
this.domain = message.domain
this.action = message.action
this.meta = JSON.stringify(message, null, 2)
this.message = ''
} catch (err) {
console.error('Cannot parse audit message.', err)
}
}
}
}
|