Skip to content
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

log the error to stderr when an error is thrown #115

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stevemao
Copy link
Contributor

@stevemao stevemao commented Mar 15, 2022

Lambda doesn't log the error automatically when it's reported. This makes it very hard to debug when integrating with other service such as API gateway. Although users of this library can print logs anywhere they want, they cannot print the error that is thrown from the library. All uncaught errors should be printed to stderr. This aligns the behaviour of other runtime engines such as Nodejs.

The logger is passed as an option so that users can choose to overwrite the format of the logs.

Before

2022-03-14T23:52:09.027+11:00 | START RequestId: 6eedee44-a17a-45c4-92f1-92b0ccc01dca Version: $LATEST
-- | --
  | 2022-03-14T23:52:09.065+11:00 | END RequestId: 6eedee44-a17a-45c4-92f1-92b0ccc01dca
  | 2022-03-14T23:52:09.065+11:00 | REPORT RequestId: 6eedee44-a17a-45c4-92f1-92b0ccc01dca Duration: 34.33 ms Billed Duration: 77 ms Memory Size: 128 MB Max Memory Used: 22 MB Init Duration: 41.72 ms

After

2022-03-15T23:08:58.239+11:00 | START RequestId: 5fe9c264-9527-4e8f-bcfd-6c1e89e7382e Version: $LATEST
-- | --
  | 2022-03-15T23:08:59.564+11:00 | 5fe9c264-9527-4e8f-bcfd-6c1e89e7382e ERROR Invocation Error {"isBase64Encoded":false,"statusCode":400,"body":"Parsing {errorMessage = \"Error in $: key \\\"resource\\\" not found\", actualValue = \"{\\\"version\\\":\\\"2.0\\\",\\\"routeKey\\\":\\\"POST /start\\\",\\\"rawPath\\\":\\\"/start\\\",\\\"rawQueryString\\\":\\\"\\\",\\\"headers\\\":{\\\"accept\\\":\\\"*/*\\\",\\\"accept-encoding\\\":\\\"gzip, deflate, br\\\",\\\"cache-control\\\":\\\"no-cache\\\",\\\"content-length\\\":\\\"14\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"host\\\":\\\"9u1pm42rf6.execute-api.ap-southeast-2.amazonaws.com\\\",\\\"postman-token\\\":\\\"3ad02f7a-20e4-499d-b748-148a17f6bc19\\\",\\\"user-agent\\\":\\\"PostmanRuntime/7.29.0\\\",\\\"x-amzn-trace-id\\\":\\\"Root=1-623081d8-5ca0569150e6d8120445a39c\\\",\\\"x-forwarded-for\\\":\\\"14.200.247.110\\\",\\\"x-forwarded-port\\\":\\\"443\\\",\\\"x-forwarded-proto\\\":\\\"https\\\"},\\\"requestContext\\\":{\\\"accountId\\\":\\\"905299074195\\\",\\\"apiId\\\":\\\"9u1pm42rf6\\\",\\\"domainName\\\":\\\"9u142rf6.execute-api.ap-southeast-2.amazonaws.com\\\",\\\"domainPrefix\\\":\\\"9u6\\\",\\\"http\\\":{\\\"m
  | 2022-03-15T23:09:00.804+11:00 | ...
  | 2022-03-15T23:09:00.824+11:00 | END RequestId: 5fe9c264-9527-4e8f-bcfd-6c1e89e7382e
  | 2022-03-15T23:09:00.824+11:00 | REPORT RequestId: 5fe9c264-9527-4e8f-bcfd-6c1e89e7382e Duration: 2583.89 ms Billed Duration: 3706 ms Memory Size: 128 MB Max Memory Used: 46 MB Init Duration: 1121.73 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant