man*_*iam 7 amazon-web-services node.js amazon-cloudwatch aws-lambda
如果我console.log('message')
在我的代码中执行,它会在Cloudwatch中显示为
2017-03-16T18:58:21.823Z 863c835c-0a7a-11e7-9140-e5018d6e5029 message
.
有没有办法删除自动格式,以便Cloudwatch只显示我传递给的参数console.log
?
在处理程序内部,您可以覆盖console.log
以直接写入stdout
:
var util = require('util')
module.exports.handler = function (event, context, done) {
console.log = function () {
var args = Array.prototype.slice.call(arguments)
process.stdout.write(args.map(function (arg) {
return util.isPrimitive(arg) ? String(arg) : util.inspect(arg)
}).join(' '))
}
// the rest of your handler...
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1411 次 |
最近记录: |