Files
enm-cli/util/logAlarm.js
2022-06-30 18:15:59 +06:00

28 lines
588 B
JavaScript
Executable File

const chalk = require('chalk')
const timeValues = [
'eventTime',
'insertTime',
'ceaseTime',
'ackTime',
]
function logAlarm(alarmList, eventPoId) {
const alarm = alarmList.find(item => item.eventPoIdAsLong === eventPoId)
timeValues.forEach(value => {
if (alarm[value]) {
alarm[value] = new Date(alarm[value]).toLocaleString()
}
})
console.log(
JSON.stringify(alarm, null, 2)
.replace(/["(){}\[\]]/mg, '')
.replace(/,$/mg, '')
.replace(/^(\s{2}\w+):/mg, chalk.green('$1:'))
)
}
module.exports = logAlarm