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

Feat improve logger information #2

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build & Release

on:
push:
branches: [master, alpha, beta, rc]
branches: [master, main, alpha, beta, rc]
pull_request:
branches: [master]
branches: [master, main]
types: [opened, synchronize, closed]

concurrency:
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
run: yarn install --immutable --network-timeout 500000
- uses: hashicorp/setup-terraform@v3
- name: Start localstack 🚧
run: yarn run start:docker -d
run: yarn run start:docker
- name: Build & Deploy lambda 🚧
run: yarn deploy:lambda
- name: Run test 🔍
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,34 @@ yarn test:e2e
Use terraform to deploy the lambda function on AWS.

```sh
TBD
yarn build:lambda
yarn deploy:lambda
```

## Contributors

Please read [contributing guidelines here](./CONTRIBUTING.md).

<a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>

## Backers

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]

<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>

## Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]

## License

The MIT License (MIT)

Copyright (c) 2016 - Today Romain Lenzotti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"deploy:lambda": "yarn workspace @project/lambda run build:deploy",
"start:www": "yarn workspace @project/www run start",
"start:lambda": "concurrently \"yarn start:docker\" \"yarn workspace @project/lambda run start\" --names docker,esbuild -c green,blue",
"start:docker": "dotenv-flow docker compose up",
"start:docker": "dotenv-flow docker compose up -- -d",
"stop:docker": "docker compose down",
"test": "vitest run",
"test:watch": "vitest run",
Expand Down
5 changes: 3 additions & 2 deletions packages/infra/aws/log-request/ServerlessLogRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class ServerlessLogRequest {

if (logEnd) {
if ($ctx.response.statusCode >= 400) {
console.log("===>", $ctx.error)
$ctx.logger.error({
event: "request.end",
status: $ctx.response.statusCode,
Expand Down Expand Up @@ -118,7 +117,9 @@ export class ServerlessLogRequest {
headers: request.headers,
body: request.body,
query: request.query,
params: request.params
params: request.params,
aws_event: ctx.event,
aws_context: ctx.context
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/lambda/src/auth/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { PlatformServerless } from "@tsed/platform-serverless"
// shared configuration
const config = {
envs: process.env,
logger: {
level: "info" as never,
requestFields: ["reqId", "method", "url", "duration", "route", "aws_event", "aws_context"]
},
auth: {
// Not applicable here because lambda are packaged and deployed on AWS.
// For this reason, we can't use the file system to store data (prefer S3, DynamoDB, etc.)
Expand Down
3 changes: 2 additions & 1 deletion packages/lambda/src/timeslots/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const config = {
envs: process.env,
lambda: [TimeslotsController],
logger: {
level: "info" as never
level: "info" as never,
requestFields: ["reqId", "method", "url", "duration", "route", "aws_event", "aws_context"]
},
timeslots: {
// Not applicable here because lambda are packaged and deployed on AWS.
Expand Down