【发布时间】:2015-10-17 12:21:43
【问题描述】:
我正在尝试使用覆盖来控制台记录此内容,但出现错误。当我删除 JSON.stringify(arguments[0]) 时,代码可以正常工作,但我需要 JSON 格式的代码。
app.use(function(req, res, next) {
var t_log= console.log;
console.log = function(){
arguments[0] = JSON.stringify(arguments[0])+" sessionID " + req.sessionID + " requestID=" + req.id +" timestamp"+ new Date();
t_log.apply(console, arguments);
}
console.log("call");
next();
});
【问题讨论】:
-
arguments[0]的开头是什么?arguments.length是什么?你遇到了什么错误? -
@Paul 我在控制台中得到了无限的 '\'。
标签: javascript json node.js express