Skip to content

Commit 6115983

Browse files
authored
Merge branch 'main' into 1568-log-message-ordering
2 parents e1539ac + 82b1f85 commit 6115983

File tree

16 files changed

+1087
-1688
lines changed

16 files changed

+1087
-1688
lines changed

.github/workflows/secure-workflows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
- name: Checkout code
3333
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3434
- name: Ensure 3rd party workflows have SHA pinned
35-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@74606c30450304eee8660aae751818321754feb1 # v3.0.9
35+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@b88cd0aad2c36a63e42c71f81cb1958fed95ac87 # v3.0.10
3636
with:
3737
allowlist: slsa-framework/slsa-github-generator

docs/core/logger.md

+20
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,26 @@ We prioritise log level settings in this order:
519519

520520
In the event you have set a log level in Powertools to a level that is lower than the ACL setting, we will output a warning log message informing you that your messages will be discarded by Lambda.
521521

522+
### Setting timestamp to custom Timezone
523+
524+
By default, Logger emits records with the default Lambda timestamp in **UTC**, i.e. `2016-06-20T12:08:10.000Z`
525+
526+
If you prefer to log in a specific timezone, you can configure it by setting the `TZ` environment variable. You can do this either as an environment variable or directly within your Lambda function settings.
527+
528+
[Click here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime){target="_blank"} for a comprehensive list of available Lambda environment variables.
529+
530+
=== "customTimezone.ts"
531+
532+
```typescript hl_lines="8"
533+
--8<-- "examples/snippets/logger/customTimezone.ts"
534+
```
535+
536+
=== "customTimezoneOutput.json"
537+
538+
```json hl_lines="7 15"
539+
--8<-- "examples/snippets/logger/customTimezoneOutput.json"
540+
```
541+
522542
### Using multiple Logger instances across your code
523543

524544
The `createChild` method allows you to create a child instance of the Logger, which inherits all of the attributes from its parent. You have the option to override any of the settings and attributes from the parent logger, including [its settings](#utility-settings), any [extra keys](#appending-additional-keys), and [the log formatter](#custom-log-formatter-bring-your-own-formatter).

docs/requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mike==1.1.2
2-
mkdocs-material==9.5.27
2+
mkdocs-material==9.5.28
33
mkdocs-git-revision-date-plugin==0.3.2
44
mkdocs-exclude==1.0.2

docs/requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ babel==2.14.0 \
88
--hash=sha256:6919867db036398ba21eb5c7a0f6b28ab8cbc3ae7a73a44ebe34ae74a4e7d363 \
99
--hash=sha256:efb1a25b7118e67ce3a259bed20545c29cb68be8ad2c784c83689981b7a57287
1010
# via mkdocs-material
11-
certifi==2023.11.17 \
12-
--hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \
13-
--hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
11+
certifi==2024.7.4 \
12+
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
13+
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
1414
# via requests
1515
charset-normalizer==3.3.2 \
1616
--hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \
@@ -235,9 +235,9 @@ mkdocs-get-deps==0.2.0 \
235235
mkdocs-git-revision-date-plugin==0.3.2 \
236236
--hash=sha256:2e67956cb01823dd2418e2833f3623dee8604cdf223bddd005fe36226a56f6ef
237237
# via -r requirements.in
238-
mkdocs-material==9.5.27 \
239-
--hash=sha256:a7d4a35f6d4a62b0c43a0cfe7e987da0980c13587b5bc3c26e690ad494427ec0 \
240-
--hash=sha256:af8cc263fafa98bb79e9e15a8c966204abf15164987569bd1175fd66a7705182
238+
mkdocs-material==9.5.28 \
239+
--hash=sha256:9cba305283ad1600e3d0a67abe72d7a058b54793b47be39930911a588fe0336b \
240+
--hash=sha256:ff48b11b2a9f705dd210409ec3b418ab443dd36d96915bcba45a41f10ea27bfd
241241
# via -r requirements.in
242242
mkdocs-material-extensions==1.3.1 \
243243
--hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \

examples/app/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"jest": "^29.7.0",
4242
"source-map-support": "^0.5.21",
4343
"ts-jest": "^29.1.5",
44-
"tsx": "^4.16.0",
44+
"tsx": "^4.16.2",
4545
"typescript": "^5.4.5"
4646
},
4747
"dependencies": {
@@ -51,8 +51,8 @@
5151
"@aws-lambda-powertools/metrics": "^2.3.0",
5252
"@aws-lambda-powertools/parameters": "^2.3.0",
5353
"@aws-lambda-powertools/tracer": "^2.3.0",
54-
"@aws-sdk/client-ssm": "^3.606.0",
55-
"@aws-sdk/lib-dynamodb": "^3.606.0",
54+
"@aws-sdk/client-ssm": "^3.609.0",
55+
"@aws-sdk/lib-dynamodb": "^3.609.0",
5656
"@middy/core": "^4.7.0",
5757
"@types/aws-lambda": "^8.10.140",
5858
"@types/jest": "^29.5.12",
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Logger } from '@aws-lambda-powertools/logger';
2+
3+
const logger = new Logger({ serviceName: 'serverlessAirline' });
4+
5+
export const handler = async (): Promise<void> => {
6+
logger.info('Hello, World!');
7+
8+
process.env.TZ = 'Europe/Rome';
9+
10+
const childLogger = logger.createChild();
11+
12+
childLogger.info('Ciao, Mondo!');
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"level": "INFO",
4+
"message": "Hello, World!",
5+
"sampling_rate": 0,
6+
"service": "serverlessAirline",
7+
"timestamp": "2024-07-01T11:00:37.886Z",
8+
"xray_trace_id": "1-66828c55-2bb635c65eb609c820ebe7bc"
9+
},
10+
{
11+
"level": "INFO",
12+
"message": "Ciao, Mondo!",
13+
"sampling_rate": 0,
14+
"service": "serverlessAirline",
15+
"timestamp": "2024-07-01T13:00:37.934+02:00",
16+
"xray_trace_id": "1-66828c55-2bb635c65eb609c820ebe7bc"
17+
}
18+
]

examples/snippets/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"@aws-lambda-powertools/parameters": "^2.3.0",
3838
"@aws-lambda-powertools/parser": "^2.3.0",
3939
"@aws-lambda-powertools/tracer": "^2.3.0",
40-
"@aws-sdk/client-appconfigdata": "^3.606.0",
41-
"@aws-sdk/client-dynamodb": "^3.606.0",
42-
"@aws-sdk/client-secrets-manager": "^3.606.0",
43-
"@aws-sdk/client-ssm": "^3.606.0",
44-
"@aws-sdk/util-dynamodb": "^3.606.0",
40+
"@aws-sdk/client-appconfigdata": "^3.609.0",
41+
"@aws-sdk/client-dynamodb": "^3.609.0",
42+
"@aws-sdk/client-secrets-manager": "^3.609.0",
43+
"@aws-sdk/client-ssm": "^3.609.0",
44+
"@aws-sdk/util-dynamodb": "^3.609.0",
4545
"@middy/core": "^4.7.0",
46-
"aws-sdk": "^2.1651.0",
46+
"aws-sdk": "^2.1652.0",
4747
"aws-sdk-client-mock": "^4.0.1",
4848
"aws-sdk-client-mock-jest": "^4.0.1",
4949
"hashi-vault-js": "^0.4.15",

0 commit comments

Comments
 (0)