Authored by yyq

add api access log

... ... @@ -33,6 +33,7 @@ module.exports = {
params: {}
},
'/api/ufo/seller/entryGoodsSizeList': {
accessLog: true,
checkSign: true,
ufo: true,
api: 'ufo.seller.entryGoodsSizeList',
... ... @@ -43,6 +44,7 @@ module.exports = {
}
},
'/api/ufo/sellerOrder/computeAdjustPrice': {
accessLog: true,
checkSign: true,
ufo: true,
api: 'ufo.sellerOrder.computeAdjustPrice',
... ... @@ -55,6 +57,7 @@ module.exports = {
}
},
'/api/ufo/sellerOrder/batchAdjustPrice': {
accessLog: true,
checkSign: true,
ufo: true,
api: 'ufo.sellerOrder.batchAdjustPrice',
... ... @@ -67,6 +70,7 @@ module.exports = {
}
},
'/api/ufo/sellerOrder/batchDownShelf': {
accessLog: true,
checkSign: true,
ufo: true,
api: 'ufo.sellerOrder.batchDownShelf',
... ...
... ... @@ -30,7 +30,7 @@ module.exports = async(req, res, next) => {
}
let baseParams;
let reqParams = Object.assign({}, req.query, req.body);
req.route = {
path: req.path
};
... ... @@ -41,6 +41,10 @@ module.exports = async(req, res, next) => {
Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString()
});
if (apiInfo.accessLog) {
logger.info(`[request access log] ${req.yoho.clientIp} | ${req.url} | uid:${req.user.uid} | User-Agent:${req.get('User-Agent')} | ${new Date()}`);
}
if (apiInfo.checkSign) {
if (!checkSign(Object.assign({}, reqParams), reqParams.s)) {
logger.error(`验签失败!uid: ${_.get(req, 'user.uid', '').toString()}, params: ${JSON.stringify(reqParams)}, ip: ${req.yoho.clientIp}`);
... ...
... ... @@ -119,7 +119,7 @@ const render = (route) => {
const isDegrade = _.get(req.app.locals.wap, 'webapp.degrade', false);
if (route.accessLog) {
logger.info(`${req.yoho.clientIp} | ${req.url} | uid:${req.user.uid} | ${new Date()}`);
logger.info(`[request access log] ${req.yoho.clientIp} | ${req.url} | uid:${req.user.uid} | User-Agent:${req.get('User-Agent')} | ${new Date()}`);
}
if (isDegrade) {
... ...