Closed jiang-wei closed 7 years ago
@allanfish 看下,这个应该要考虑兼容性
另外代码里判断 logger 不是 function 时就用 console替换掉了 winston 的 logger 都是 objcet,该怎么使用呢?
@allanfish 有头绪吗?
@jiang-wei 已经解决了 默认有支持.
如果使用winston. 建议在配置cas的时候传进来:
logger: (req, type) => {
switch (type) { // cas日志不用那么详细, 有问题后再打开
case 'log':
case 'debug':
case 'info':
return winston.info(...);
case 'warn':
case 'error':
return winston.error(...);
default:
return winston.log(...);
}
},
解决了
logger: (req, type) => {
switch(type) {
case 'log':
case 'debug':
return casLogger.debug.bind(casLogger);
case 'access':
case 'info':
return casLogger.info.bind(casLogger);
case 'warn':
case 'error':
return casLogger.error.bind(casLogger);
default:
return casLogger.log.bind(casLogger);
}
},
....
不配置 log 时,应该就是使用默认的 console 可是代码里用了 logger.access ,所对应的 console 缺没有 access 方法,会造成输出失败。 在使用时还要自己定义一个 console.access = console.log 先 请考虑修改