添加日志相关功能
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
const express = require('express');
|
||||
const engine = require('../engine');
|
||||
const { loadConfigFromText, readConfigText, applyEditsToText, writeConfigText } = require('../config');
|
||||
const log = require('../log');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -61,7 +62,7 @@ router.put('/', wrap((req, res) => {
|
||||
let next;
|
||||
try { next = loadConfigFromText(text, cfg.config_path); } catch (e) { return badRequest(res, e); }
|
||||
writeConfigText(cfg, text);
|
||||
console.log('[config] ' + (req.user || '-') + ' 整文件保存配置,变更段:' + (diffTop(cfg, next).join(',') || '无'));
|
||||
log.info('[config] ' + (req.user || '-') + ' 整文件保存配置,变更段:' + (diffTop(cfg, next).join(',') || '无'));
|
||||
res.json({ ok: true, changed: diffTop(cfg, next), restart_required: true });
|
||||
}));
|
||||
|
||||
@@ -84,7 +85,7 @@ router.patch('/', wrap((req, res) => {
|
||||
let next;
|
||||
try { next = loadConfigFromText(nextText, cfg.config_path); } catch (e) { return badRequest(res, e); }
|
||||
writeConfigText(cfg, nextText);
|
||||
console.log('[config] ' + (req.user || '-') + ' 修改配置项 ' + pathArr.join('.') + (body.op === 'delete' ? '(删除)' : '') + ',变更段:' + (diffTop(cfg, next).join(',') || '无'));
|
||||
log.info('[config] ' + (req.user || '-') + ' 修改配置项 ' + pathArr.join('.') + (body.op === 'delete' ? '(删除)' : '') + ',变更段:' + (diffTop(cfg, next).join(',') || '无'));
|
||||
res.json({ ok: true, changed: diffTop(cfg, next), restart_required: true });
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user