Commit 82e44cab by 宋毅

tj

parent c008b5c5
...@@ -4,9 +4,9 @@ var settings = require("../../../../config/settings"); ...@@ -4,9 +4,9 @@ var settings = require("../../../../config/settings");
class OplogService extends ServiceBase { class OplogService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(OplogService)); super("common", ServiceBase.getDaoName(OplogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl(); this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd(); this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
this.logCtl = system.getObject("service.common.oplogSve");
} }
async error(qobj) { async error(qobj) {
this.create(qobj); this.create(qobj);
...@@ -15,65 +15,37 @@ class OplogService extends ServiceBase { ...@@ -15,65 +15,37 @@ class OplogService extends ServiceBase {
this.create(qobj); this.create(qobj);
} }
async create(qobj) { async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
var rc = system.getObject("util.execClient"); var rc = system.getObject("util.execClient");
var rtn = null;
try { try {
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle; qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
if (this.opLogEsIsAdd == 1) { if (this.opLogEsIsAdd == 1) {
qobj.content = qobj.content.replace("field list", "字段列表") qobj.content = qobj.content.replace("field list", "字段列表")
qobj.created_at = (new Date()).getTime(); qobj.created_at = (new Date()).getTime();
//往Es中写入日志 //往Es中写入日志
var addEsData = JSON.stringify(qobj);
rc.execPost(qobj, this.opLogUrl); rc.execPost(qobj, this.opLogUrl);
} else { } else {
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj); this.dao.create(qobj);
} }
} catch (e) { } catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack; qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj); this.dao.create(qobj);
} }
} }
async createDb(qobj) { async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
try { try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle; qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj); this.dao.create(qobj);
} catch (e) { } catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************"); //日志记录
qobj.content = e.stack; this.logCtl.error({
//解决日志大于4000写入的问题 appid: qobj.appid || "",
if (qobj.content.length > 4980) { appkey: qobj.appkey || "",
qobj.content = qobj.content.substring(0, 4980); requestId: qobj.requestId || "",
} op: qobj.op || "",
this.dao.create(qobj); content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_log->createDb",
});
} }
} }
} }
......
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