Authored by shuaiguo

Merge branch 'feature/accessLog' into 'master'

add accesslog



See merge request !26
module.exports = [
{
route: /mapp\/order\/ufo\/\d+\.html/,
accessLog: true
},
{
route: /mapp\/coupon\/ufo/,
... ...
... ... @@ -118,6 +118,10 @@ const render = (route) => {
res.setHeader('X-YOHO-Version', pkg.version);
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()}`);
}
if (isDegrade) {
return res.send(degradeHtml);
}
... ... @@ -163,7 +167,7 @@ const render = (route) => {
zk,
routeHash: routeEncode.getRouter(req)
});
if (config.useCache && route.cache && ck) {
redis.setex(ck, route.cacheTime || 60, result);
... ... @@ -181,6 +185,10 @@ const devRender = (route) => {
res.setHeader('X-YOHO-Version', pkg.version);
const ck = route.cackeKey ? getCacheKey(req.url, route.cackeKey) : void 0;
if (route.accessLog) {
logger.info(`${req.yoho.clientIp} | ${req.url} | uid:${req.user.uid} | ${new Date()}`);
}
// return require('request-promise')({
// url: 'http://m.yohobuy.com:6005/degrade.html'
// }).pipe(res);
... ...