-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam logs output mangled #1359
Comments
I have to dig into this more. But I think this is a bug where multiline logs aren't handled well. |
@sanathkr I'm also observing this issue in |
Also experiencing this issue since upgrading to 0.21.0 with Node.js 10.x I have been using console.dir for now which seems to be ok. |
I've used this to make it work properly on mac:
|
To add to this, it is also an issue when using sam local. |
thanks @wmonk very helpful. For some reason that didn't quite work for me but I did adapt it to the below and it seems to have sorted the issue with multiline logs (particularly logging large nested objects):
|
Yep sorry should have mentioned, to get |
Is there a permanent fix for this yet. I'm seeing the same behavior in |
This is due to some unfortunate internal changes in the runtimes where It's always been docker-lambda's policy to make as minimal changes as possible to the runtimes so that the docker images are as close to production as possible – and this extends to the logging. Workarounds are just writing straight to |
Ok, you know what – after some thinking about it, I decided to fix this issue by changing docker-lambda's behaviour. I now transform So basically, your logs should look fine now. If you're outputting @sanathkr you can probably consider this issue closed unless you want to do something on the aws-sam-cli end |
@mhart Thanks for jumping on this and fixing. I will close the issue. |
I am having this issue with version 1.13.2 using local invoke. I have not tested it with logs yet. This issue was not there with the previous version I was using which was 1.3.0. |
I take it back. I just downgraded to 1.3.0 and the issue is there. Anything with JSON.stringify will get mangled using local invoke. Can only see the fist line and the last line. So anything with \n or \r will not work. For example.
will output
Should I start a new issue for this or can this issue be re-opened? Edit: @mhart the above code will work but this is still a bug and should be re-opened. |
@code-is-art SAM CLI no longer uses the docker-lambda containers where this issue was originally fixed. Might want to open an issue over at https://github.com/aws/aws-lambda-runtime-interface-emulator |
Thank you |
Hi there, However, this issue has been opened for two years and it seems like it should be fixed, can you either give a reason not fix the issue and add a gentle note to the sam cli documentation (with that workaround), or fix it? If not planning to fix, adding a note to the docs will save time to figure it out -- many people like me could waste a lot of time thinking they are doing something wrong. thanks |
For anyone looking for workaround that works for windows PowerShell: |
I'm losing faith in AWS. It has been 2 years, this issue affects most of the users of this tool, and the issue is closed. |
2022... any fix for this dumb behaviour?? |
I try appending |
My team is abandoning Lambda due to the atrocious support and bugginess of the SAM tool. Dealing with SAM tool issues has eaten more time than anything else I've ever seen in development. |
The real solution is the friends we made along the way. And just not using console.log |
My favorite part is how this is has been a major issue for over a year yet this issue sits here closed |
omg, they've fixed it! seems to finally be fixed in 1.98.0! ❤️ ❤️ ❤️ for anyone who can't upgrade yet, the only workaround I found that worked was |
Description
When I use
sam logs
to view my lambda function logs from the console (OSX terminal) my log messages are mangled. Note, I don't expect them to be pretty printed, but the output below is mangled.Here is the view from CloudWatch Management Console:
Steps to reproduce
I am producing these log messages like this (Node 10.x):
console.debug(JSON.stringify({ ozowResponse }, null, 2));
Observed result
See description above.
Expected result
I printed four log messages. Two console.debugs and two console.errors. I expect to see these four log messages as in the
sam logs
output.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 0.17.0Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: