Commit 88e24c2b by 蒋勇

d

parent 2eaa1def
......@@ -4,6 +4,7 @@ const settings = require("../../config/settings");
class APIBase{
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
this.logClient=system.getObject("util.logClient");
}
getUUID() {
var uuid = uuidv4();
......@@ -51,39 +52,10 @@ class APIBase{
}
var rtn = await this[methodname](pobj, query, req);
rtn.requestId=this.getUUID()
req.params.param=pobj
let t=req.xctx.codetitle
if(t==''){
t="外部调用"
}
system.execLogs(t,req.params,pobj.company_id,rtn,null).then(res=>{
if(res && res.status==1){
console.log("log.....success")
}else{
console.log("log.....fail")
}
}).catch(e=>{
console.log("log.....fail")
})
this.logClient.log(pobj,req,rtn)
return rtn;
} catch (e) {
let rtn={}
rtn.requestId=this.getUUID()
req.params.param=pobj
let t=req.xctx.codetitle
if(t==''){
t="外部调用"
}
system.execLogs(t,req.params,pobj.company_id,rtn,e.stack).then(res=>{
if(res && res.status==1){
console.log("log.....success")
}else{
console.log("log.....fail")
}
}).catch(e=>{
console.log("log.....fail")
})
this.logClient.log(pobj,req,{})
console.log(e.stack, "api调用异常--error...................");
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
return rtnerror;
......
......@@ -6,6 +6,7 @@ class CtlBase {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager");
this.logClient=system.getObject("util.logClient");
}
getUUID() {
var uuid = uuidv4();
......@@ -85,20 +86,7 @@ class CtlBase {
}
pobj.bizpath = req.xctx.bizpath;
}
async log(pobj, req, rtn) {
rtn.requestId = this.getUUID()
req.params.param = pobj
//第三个字段应该存公司id
system.execLogs(req.xctx.codetitle, req.params, pobj.company_id, rtn, null).then(res => {
if (res && res.status == 1) {
console.log("log.....success")
} else {
console.log("log.....fail")
}
}).catch(e => {
console.log("log.....fail")
})
}
async doexec(methodname, pobj, query, req) {
try {
let xarg = await this.setContextParams(pobj, query, req);
......@@ -106,10 +94,10 @@ class CtlBase {
return system.getResultFail(...xarg);
}
var rtn = await this[methodname](pobj, query, req);
//this.log(pobj,req,rtn)
this.logClient.log(pobj,req,rtn)
return rtn;
} catch (e) {
//this.log(pobj,req,rtn)
this.logClient.log(pobj,req,{})
console.log(e.stack, "出现异常,请联系管理员.......");
return system.getResultFail(-200, "出现异常,请联系管理员");
}
......
// var log4js = require('log4js');
var settings=require("../../config/settings");
class LogClient{
constructor(){
// log4js.configure(settings.basepath+"/app/config/log4js.json");
// this.logerApp=log4js.getLogger("app");
// this.logerHttp=log4js.getLogger("http");
}
var settings = require("../../config/settings");
const uuidv4 = require('uuid/v4');
const system = require("../system");
class LogClient {
constructor() {
// log4js.configure(settings.basepath+"/app/config/log4js.json");
// this.logerApp=log4js.getLogger("app");
// this.logerHttp=log4js.getLogger("http");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async log(pobj, req, rtn) {
rtn.requestId = this.getUUID()
req.params.param = pobj
//第三个字段应该存公司id
system.execLogs(req.xctx.codetitle, req.params, pobj.company_id, rtn, null).then(res => {
if (res && res.status == 1) {
console.log("log.....success")
} else {
console.log("log.....fail")
}
}).catch(e => {
console.log("log.....fail")
})
}
}
module.exports=LogClient;
module.exports = LogClient;
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