Commit 2c75b1e6 authored by 智勇's avatar 智勇

配置管理增加日志

parent e32078bb
...@@ -107,8 +107,48 @@ exports.save = async function () { ...@@ -107,8 +107,48 @@ exports.save = async function () {
console.log(req) console.log(req)
if (req._id) { if (req._id) {
this.body = await this.mongo("dbconfig").updateById(req._id, new_db); this.body = await this.mongo("dbconfig").updateById(req._id, new_db);
try {
this.logger.info(
{
active: "update_dbconfig",
microservice_name: req.dbname.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
detail: {
dbname: req.dbname.trim(),
ip: req.ip.trim(),
port: parseInt(req.port),
username: req.username.trim() || "",
passwd: req.passwd.trim() || "",
table_list: req.table_list.trim() || "",
update_at: req.update_at
}
});
} catch (error) {
console.log(error)
}
} else { } else {
this.body = await this.mongo("dbconfig", new_db).saveByName(req.dbname, req); this.body = await this.mongo("dbconfig", new_db).saveByName(req.dbname, req);
try {
this.logger.info(
{
active: "new_dbconfig",
microservice_name: req.dbname.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
detail: {
dbname: req.dbname.trim(),
ip: req.ip.trim(),
port: parseInt(req.port),
username: req.username.trim() || "",
passwd: req.passwd.trim() || "",
table_list: req.table_list.trim() || "",
update_at: req.update_at
}
});
} catch (error) {
console.log(error)
}
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error)
...@@ -145,6 +185,17 @@ exports.delete = async function () { ...@@ -145,6 +185,17 @@ exports.delete = async function () {
await this.bindDefault(); await this.bindDefault();
try { try {
await this.mongo("dbconfig").delete(this.request.query._id) await this.mongo("dbconfig").delete(this.request.query._id)
try {
this.logger.info(
{
active: "delete_dbconfig",
microservice_name: this.request.query.dbname.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
});
} catch (error) {
console.log(error)
}
this.body = { code: "0002" } this.body = { code: "0002" }
} catch (error) { } catch (error) {
//执行不到这里,即使删除前将要删除的记录手动删除了,也不会报错 //执行不到这里,即使删除前将要删除的记录手动删除了,也不会报错
......
...@@ -60,8 +60,32 @@ exports.save = async function () { ...@@ -60,8 +60,32 @@ exports.save = async function () {
console.log(req) console.log(req)
if (req._id) { if (req._id) {
this.body = await this.mongo("ProConfig").updateById(req._id, new_pro); this.body = await this.mongo("ProConfig").updateById(req._id, new_pro);
try {
this.logger.info(
{
active: "update_proconfig",
microservice_name: project_name.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
detail: new_pro
});
} catch (error) {
console.log(error)
}
} else { } else {
this.body = await this.mongo("ProConfig", new_pro).saveByPath(req.git_path, req); this.body = await this.mongo("ProConfig", new_pro).saveByPath(req.git_path, req);
try {
this.logger.info(
{
active: "new_proconfig",
microservice_name: project_name.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
detail: new_pro
});
} catch (error) {
console.log(error)
}
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error)
...@@ -135,6 +159,17 @@ exports.delete = async function () { ...@@ -135,6 +159,17 @@ exports.delete = async function () {
await this.bindDefault(); await this.bindDefault();
let item = await this.mongo("ProConfig").delete(this.request.query._id); let item = await this.mongo("ProConfig").delete(this.request.query._id);
this.body = item this.body = item
try {
this.logger.info(
{
active: "delete_proconfig",
microservice_name: this.request.query.project_name.trim(),
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
});
} catch (error) {
console.log(error)
}
return return
} }
exports.delete.__method__ = 'get'; exports.delete.__method__ = 'get';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment