dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.2k stars 795 forks source link

Logs in golang are not displayed in the console (Windows) #1352

Open walterdl opened 2 years ago

walterdl commented 2 years ago

Bug Report

I'm facing a weird behavior with golang and serverless-offline on windows; any log produced with the standard packages log and fmt are not shown in the console and some of them are sent as the HTTP response when the lambda is triggered as an HTTP endpoint.

Current Behavior

Sample Code

Expected behavior/code

The logs from log.Print and fmt.Println should be shown in the console. They should not be shown as the HTTP response or break the service by returning 502 Status code.

Environment

optional, if you are using any of the following frameworks to invoke handlers

Possible Solution

Additional context/Screenshots

pgrzesik commented 2 years ago

Hey @walterdl - thanks for reporting.

Hey @icarus-sullivan - do you think would be able to take a look at it? I'm not very experienced with Golang so it might be hard for me to take a deeper look into it.

icarus-sullivan commented 2 years ago

@pgrzesik I have an update to the mock-lambda go implementation that needs to be merged which might fix this issue. Will hopefully have some time this weekend to take a look.

pgrzesik commented 2 years ago

Thanks a lot @icarus-sullivan 🙇

icarus-sullivan commented 2 years ago

@walterdl @pgrzesik Hey folks, ran some tests locally. Seems log is being construed as stderr in the response even though it's technically not an error. I'm going to test some more scenario's where an actual error occurs in the lambda to see what occurs. Worst case scenario we merge all stderr and stdout when parsing the payload and output it as expected.

icarus-sullivan commented 2 years ago

@pgrzesik PR here https://github.com/dherault/serverless-offline/pull/1355

youg9203 commented 1 year ago

Any update on this? I'm facing the same issue on Mac OS, running serverless offline and unable to print the logs in the console.

    "serverless": "3.22.0",
    "serverless-apigateway-service-proxy": "2.2.0",
    "serverless-apigw-binary": "0.4.4",
    "serverless-cloudformation-sub-variables": "0.2.1",
    "serverless-deployment-bucket": "1.6.0",
    "serverless-domain-manager": "6.1.0",
    "serverless-dynamodb-local": "0.2.40",
    "serverless-git-info": "1.2.3",
    "serverless-offline": "11.0.3",
    "serverless-plugin-conditional-functions": "1.0.7",
    "serverless-plugin-ifelse": "1.0.7",
    "serverless-prune-plugin": "2.0.1",
    "serverless-s3-cleaner": "2.0.1"

Additionally GoLang bersion go version: go1.19.3 darwin/amd64

abdullateef97 commented 3 weeks ago

@youg9203 please I don't know if you found a work around for this, @walterdl as well

abdullateef97 commented 3 weeks ago

@pgrzesik please the bug is still existing

abdullateef97 commented 3 weeks ago

@DorianMazur please take a look here