文件
jw-beauty/cloud/common/log.js
T

28 行
864 B
JavaScript

var db = require('./db')
async function writeLog(options) {
try {
await db.insert(
'INSERT INTO operation_logs (operator_type, operator_id, target_type, target_id, action, before_snapshot, after_snapshot, ip_address, user_agent, remark) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[
options.operator_type || 2,
options.operator_id || null,
options.target_type || '',
options.target_id || null,
options.action || '',
options.before_snapshot ? JSON.stringify(options.before_snapshot) : null,
options.after_snapshot ? JSON.stringify(options.after_snapshot) : null,
options.ip_address || null,
options.user_agent || null,
options.remark || null
]
)
} catch (e) {
console.error('writeLog failed:', e.message)
}
}
module.exports = {
writeLog: writeLog
}