Skip to content

Commit 6dad13b

Browse files
committed
Merge branch '751-feature-logger-pretty-printing-logs-in-local-and-non-prod-env' of https://github.com/shdq/aws-lambda-powertools-typescript into 751-feature-logger-pretty-printing-logs-in-local-and-non-prod-env
2 parents 1c2ef89 + a01459b commit 6dad13b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+9788
-668
lines changed

Diff for: .devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"ms-azuretools.vscode-docker"
2727
],
2828
// Use 'postCreateCommand' to run commands after the container is created.
29-
"postCreateCommand": "npm ci --foreground-scripts; cd examples/cdk; npm ci; cd ../sam; npm ci; cd ../../; npm run init-environment",
29+
"postCreateCommand": "npm run setup-local",
3030
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
3131
"remoteUser": "node"
3232
}

Diff for: .github/ISSUE_TEMPLATE/maintenance.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ body:
5353
options:
5454
- label: This request meets [Lambda Powertools Tenets](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#tenets)
5555
required: true
56-
- label: Should this be considered in other Lambda Powertools languages? i.e. [TypeScript](https://github.com/awslabs/aws-lambda-powertools-typescript/), [Java](https://github.com/awslabs/aws-lambda-powertools-java/)
56+
- label: Should this be considered in other Lambda Powertools languages? i.e. [Python](https://github.com/awslabs/aws-lambda-powertools-python/), [Java](https://github.com/awslabs/aws-lambda-powertools-java/)
5757
required: false
5858
- type: markdown
5959
attributes:

Diff for: .github/workflows/make-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ concurrency:
55
group: on-release-publish
66
jobs:
77
run-unit-tests:
8-
uses: ./.github/workflows/reusable-run-unit-tests.yml
8+
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml
99
publish-npm:
1010
needs: run-unit-tests
1111
runs-on: ubuntu-latest

Diff for: .github/workflows/on-merge-to-main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run-unit-tests:
2121
needs: get_pr_details
2222
if: ${{ needs.get_pr_details.outputs.prIsMerged == 'true' }}
23-
uses: ./.github/workflows/reusable-run-unit-tests.yml
23+
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml
2424
publish:
2525
needs:
2626
[get_pr_details, run-unit-tests]

Diff for: .github/workflows/pr_lint_and_test.yml renamed to .github/workflows/pr-run-linting-check-and-unit-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ on:
55
types: [opened, synchronize]
66
jobs:
77
run-unit-tests:
8-
uses: ./.github/workflows/reusable-run-unit-tests.yml
8+
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml

Diff for: .github/workflows/reusable-run-unit-tests.yml renamed to .github/workflows/reusable-run-linting-check-and-unit-tests.yml

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55

66
jobs:
7-
run-unit-tests-on-utils:
7+
run-linting-check-and-unit-tests-on-utilities:
88
runs-on: ubuntu-latest
99
env:
1010
NODE_ENV: dev
@@ -29,21 +29,21 @@ jobs:
2929
path: "./node_modules"
3030
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
3131
# if one of them changes the cache is invalidated/discarded
32-
key: ${{ matrix.version }}-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }}
32+
key: ${{ matrix.version }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
3333
- name: Install dependencies
34-
# We can skip the install if there was a cache hit
34+
# We can skip the installation if there was a cache hit
3535
if: steps.cache-node-modules.outputs.cache-hit != 'true'
3636
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
3737
run: npm ci --foreground-scripts
3838
- name: Build packages
3939
# If there's a cache hit we still need to manually build the packages
4040
# this would otherwise have been done automatically as a part of the
41-
# postinstall npm hook
41+
# post-install npm hook
4242
if: steps.cache-node-modules.outputs.cache-hit == 'true'
4343
run: |
4444
npm run build -w packages/commons
4545
npm run build -w packages/logger & npm run build -w packages/tracer & npm run build -w packages/metrics
46-
- name: Lint
46+
- name: Run linting
4747
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics
4848
- name: Run unit tests
4949
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics
@@ -77,9 +77,11 @@ jobs:
7777
# invalidated/discarded for all.
7878
key: ${{ matrix.example }}-cache-examples-node-modules-${{ hashFiles('./examples/*/package-lock.json') }}
7979
- name: Install dependencies
80-
# We can skip the install if there was a cache hit
80+
# We can skip the installation if there was a cache hit
8181
if: steps.cache-node-modules.outputs.cache-hit != 'true'
8282
run: npm ci
83+
- name: Run linting
84+
run: npm run lint
8385
- name: Run tests
8486
run: npm t
8587
check-layer-publisher:
@@ -103,8 +105,12 @@ jobs:
103105
with:
104106
path: "./layer-publisher/node_modules"
105107
# Use the combo between example, name, and SHA-256 hash of the layer-publisher lock files as cache key.
106-
key: cache-layer-publisher-node-modules-${{ hashFiles('./layer-publisher/*/package-lock.json') }}
108+
key: cache-layer-publisher-node-modules-${{ hashFiles('./layer-publisher/package-lock.json') }}
107109
- name: Install Layer publisher
108-
# We can skip the install if there was a cache hit
110+
# We can skip the installation if there was a cache hit
109111
if: steps.cache-node-modules.outputs.cache-hit != 'true'
110112
run: npm ci
113+
- name: Run linting
114+
run: npm run lint
115+
- name: Run tests
116+
run: npm t

Diff for: .gitpod.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,13 @@ tasks:
55
nvm use
66
# Install npm 8.x
77
npm i -g npm@next-8
8-
# Install monorepo packages
9-
npm ci --foreground-scripts
10-
# Install CDK exampels dependencies
11-
cd examples/cdk
12-
npm ci
13-
# Install SAM exampels dependencies
14-
cd ../sam
15-
npm ci
168
# Install AWS SAM CLI
179
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip
1810
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
1911
sudo ./sam-installation/install
2012
rm -rf sam-installation aws-sam-cli-linux-*
21-
cd ../../
22-
# Setup husky hooks
23-
npm run init-environment
13+
# Install repo dependencies
14+
npm run setup-local
2415
vscode:
2516
extensions:
2617
- dbaeumer.vscode-eslint

Diff for: .husky/pre-commit

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run lerna-lint-fix
4+
npm run lint-fix -ws
5+
cd examples/sam && npm run lint-fix
6+
cd ../..
7+
cd examples/cdk && npm run lint-fix
8+
cd ../..
9+
cd layer-publisher && npm run lint-fix
10+
cd ..

Diff for: .husky/pre-push

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run lerna-lint-fix
5-
npm run test
4+
npm t -ws

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.4.1](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v1.4.0...v1.4.1) (2022-11-09)
7+
8+
9+
### Bug Fixes
10+
11+
* **metrics:** store service name in defaultDimensions to avoid clearing it ([#1146](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/1146)) ([a979202](https://github.com/awslabs/aws-lambda-powertools-typescript/commit/a979202ae0563f8ce00dee98bbf15d0bcfcfd3cc))
12+
13+
14+
15+
16+
617
# [1.4.0](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v1.3.0...v1.4.0) (2022-10-27)
718

819

Diff for: CONTRIBUTING.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ the [eslint extension](https://marketplace.visualstudio.com/items?itemName=dbaeu
8888
### Repo Layout
8989

9090
The AWS Lambda Powertools is a npm project written in [TypeScript](https://www.typescriptlang.org/).
91-
More specifically, it is a [monorepo managed using lerna](https://github.com/lerna/lerna#about).
91+
More specifically, it is a [monorepo managed using npm workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces).
9292
If you're unfamiliar with any of these technologies, it is useful to learn about them and will make understanding the codebase easier but strictly not necessary for simple contributions.
9393

9494
The repo contains `packages/` directory that contains the Powertools utilities modules. For instance, the source code for the Logger utility can be found at the location `packages/logger` and so on.
@@ -126,9 +126,8 @@ As mentioned before, tests are split into groups thanks to [jest-runner-groups](
126126

127127
To run unit tests, you can either use:
128128

129-
* npm task `lerna-test:unit` (`npm run lerna-test:unit`) in root folder to run them all
130-
* npm task `test:unit` (`npm run test:unit`) in module folder (for example: `packages/metrics`) to run the module specific ones
131-
* jest directly `npx jest --group=unit` in module folder to run the module specific ones (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=unit/metrics/class`)
129+
* `npm test -ws` while in the root folder to run them all
130+
* `npm test -w packages/metrics` while in the root folder to run the module specific ones
132131

133132
#### e2e tests
134133

@@ -156,9 +155,8 @@ See `metrics/tests/e2e/basicFeatures.decorator.test.ts` as an example.
156155

157156
To run e2e tests, you can either use:
158157

159-
* npm task `lerna-test:e2e` (`npm run lerna-test:e2e`) in root folder
160-
* npm task `test:e2e` (`npm run test:e2e`) in module folder (for example: `packages/metrics`) to run the module specific ones
161-
* jest directly `npx jest --group=e2e` in module folder. (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=e2e/metrics/decorator`)
158+
* `npm test:e2e -ws` while in the root folder to run them all
159+
* `npm test:e2e -w packages/metrics` while in the root folder to run the module specific ones
162160

163161
Three important environment variables can be used:
164162

@@ -200,7 +198,7 @@ As part of the repo you will find an examples folder at the root. This folder co
200198

201199
To test your updates with these examples, you just have to:
202200

203-
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package` while in the root folder
201+
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run package -ws` while in the root folder
204202
2. Move to the examples folder of your choice
205203
```sh
206204
cd packages/examples/cdk

Diff for: docs/core/logger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Your Logger will include the following keys to your structured logging (default
105105
| **error**: `Object` | `{ name: "Error", location: "/my-project/handler.ts:18", message: "Unexpected error #1", stack: "[stacktrace]"}` | Optional - An object containing information about the Error passed to the logger |
106106

107107
???+ info
108-
When `POWERTOOLS_DEV` environment variable is present and set to `"true"`, Logger will pretty-print log messages for easier readability. It is for debugging purposes and is not supposed to use in production environment.
108+
When `POWERTOOLS_DEV` environment variable is present and set to `"true"` or `"1"`, Logger will pretty-print log messages for easier readability. We recommend to use this setting only when debugging on local environments.
109109

110110
### Capturing Lambda context info
111111

Diff for: docs/core/tracer.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
7575

7676
// You can also pass the parameter in the constructor
7777
// const tracer = new Tracer({
78-
// serviceName: "serverlessAirline"
78+
// serviceName: 'serverlessAirline'
7979
// });
8080
```
8181

@@ -510,7 +510,7 @@ Tracer exposes a `getRootXrayTraceId()` method that allows you to retrieve the [
510510
return {
511511
statusCode: 500,
512512
body: `Internal Error - Please contact support and quote the following id: ${rootTraceId}`,
513-
headers: { "_X_AMZN_TRACE_ID": rootTraceId },
513+
headers: { '_X_AMZN_TRACE_ID': rootTraceId },
514514
};
515515
}
516516
};

0 commit comments

Comments
 (0)