aws / aws/aws-lambda-runtime-interface-emulator

logs not showing correctly when using sam

未关闭
#15 18 条评论 52 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Go
星标
1.1k
派生
118
平均合并
42 分钟
30 天内合并 PR
2

描述

**Description**
When using sam invoke, the output of `console.log` is not displayed correctly as described in [this issue](https://github.com/aws/aws-sam-cli/issues/1359).

**Steps to reproduce**
`console.log('line one\rline two\rline three\nline four\nline five')`

will output

> START RequestId: ac1ef293-d504-16a9-6b21-20a04c7f98e6 Version: $LATEST
> line fiveeT14:12:51.527Z ac1ef293-d504-16a9-6b21-20a04c7f98e6 INFO line one
> END RequestId: ac1ef293-d504-16a9-6b21-20a04c7f98e6

and
`console.log(json.stringify({one: 'line one', two: 'line two', three: 'line three', four: 'line four'}, null, 2))`
is just as problematic. One can only read the first and last lines, usually `{` and` }`

According to @mhart

> This is due to some unfortunate internal changes in the runtimes where console.log is overwritten by a function that transforms all newlines to \r.

**Additional environment details**
os: OSX 10.14.6
sam cli versions tested: 1.3.0, 1.12.0, 1.13.2

贡献指南

打开贡献指南

调研方向

首先使用 issue 中的示例,通过 sam invoke 重现多行 console.log 输出,然后跟踪 runtime interface emulator 如何处理控制台输出和换行符。完成的标准是回车符和多行日志(包括格式化的 JSON)都能正确显示。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。