You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| AWS Lambda Powertools for TypeScript is currently released as a beta developer preview and is intended strictly for feedback purposes only. <br/>This version is not stable, and significant breaking changes might incur as part of the upcoming [production-ready release](https://github.com/awslabs/aws-lambda-powertools-typescript/milestone/2). |_
7
6
8
-
Which will also generate coverage reports, and fail if the coverage is below the threshold.
9
7
10
-
## Code Styling and Linting
11
-
### Linting
12
-
Linting standards adhear to [tslint:recommended](https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts).
8
+
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools [Python](https://github.com/awslabs/aws-lambda-powertools-python) and [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
13
9
14
-
Please ensure you run `npm run lerna-lint` before comiting to check for styling errors
The repo is setup using [Prettier](https://prettier.io/). This will automatically make syntactic changes to files to
19
-
align them with the style guides. Please run this before creating a PR, and commit the changes.
14
+
### Features
20
15
21
-
`npm run lerna-format`
16
+
***[Tracer](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/tracer/)** - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions
17
+
***[Logger](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/logger/)** - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context
18
+
***[Metrics](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF)
19
+
20
+
21
+
## Getting started
22
+
23
+
Find the complete project's [documentation here](https://awslabs.github.io/aws-lambda-powertools-typescript).
24
+
25
+
### Installation
26
+
27
+
The AWS Lambda Powertools TypeScript utilities follow a modular approach, similar to the official [AWS SDK v3 for JavaScript](https://github.com/aws/aws-sdk-js-v3).
28
+
Each TypeScript utility is installed as standalone NPM package.
29
+
30
+
👉 [Installation guide for the **Tracer** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/tracer#getting-started)
31
+
32
+
👉 [Installation guide for the **Logger** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/logger#getting-started)
33
+
34
+
👉 [Installation guide for the **Metrics** utility](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/metrics#getting-started)
*Structured logging initial implementation from [aws-lambda-logging](https://gitlab.com/hadrien/aws_lambda_logging)
26
-
* Powertools idea [DAZN Powertools](https://github.com/getndazn/dazn-lambda-powertools/)
45
+
*Credits for the Lambda Powertools idea go to [DAZN](https://github.com/getndazn) and their [DAZN Lambda Powertools](https://github.com/getndazn/dazn-lambda-powertools/).
46
+
27
47
28
-
## Security
48
+
## Connect
29
49
30
-
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
50
+
***AWS Developers Slack**: `#lambda-powertools`** - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw)**
Copy file name to clipboardExpand all lines: docs/core/logger.md
+54-29
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,14 @@ title: Logger
3
3
description: Core utility
4
4
---
5
5
6
+
!!! warning "Do not use this library in production"
7
+
8
+
AWS Lambda Powertools for TypeScript is currently released as a beta developer preview and is intended strictly for feedback purposes only.
9
+
This version is not stable, and significant breaking changes might incur as part of the upcoming [production-ready release](https://github.com/awslabs/aws-lambda-powertools-typescript/milestone/2){target="_blank"}.
10
+
11
+
**Do not use this library for production workloads.**
12
+
13
+
6
14
Logger provides an opinionated logger with output structured as JSON.
7
15
8
16
## Key features
@@ -14,14 +22,31 @@ Logger provides an opinionated logger with output structured as JSON.
**Logging level** | Sets how verbose Logger should be (INFO, by default). Supported values are: `DEBUG`, `INFO`, `WARN`, `ERROR` | `LOG_LEVEL` | `logLevel`
22
44
**Service name** | Sets the name of service of which the Lambda function is part of, that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `serviceName`
23
45
24
-
> Example using AWS Serverless Application Model (SAM)
46
+
47
+
For a **complete list** of supported environment variables, refer to [this section](./../index.md#environment-variables).
48
+
49
+
#### Example using AWS Serverless Application Model (SAM)
### Appending persistent additional log keys and values
158
183
159
184
You can append additional persistent keys and values in the logs generated during a Lambda invocation using either mechanism:
@@ -422,12 +447,12 @@ This number represents the probability that a Lambda invocation will print all t
422
447
For example, by setting the "sample rate" to `0.5`, roughly 50% of your lambda invocations will print all the log items, including the `debug` ones.
423
448
424
449
!!! tip "When is this useful?"
425
-
In production, to avoid log data pollution and reduce CloudWatch costs, developers are encouraged to use the logger with `logLevel` equal to `ERROR` or `WARN`.
426
-
This means that only errors or warnings will be printed.
427
-
428
-
However, it might still be useful to print all the logs (including debug ones) of a very small percentage of invocations to have a better understanding of the behaviour of your code in production even when there are no errors.
429
-
430
-
Sampling decision happens at the Logger initialization. This means sampling may happen significantly more or less than depending on your traffic patterns, for example a steady low number of invocations and thus few cold starts.
450
+
In production, to avoid log data pollution and reduce CloudWatch costs, developers are encouraged to use the logger with `logLevel` equal to `ERROR` or `WARN`.
451
+
This means that only errors or warnings will be printed.
452
+
453
+
However, it might still be useful to print all the logs (including debug ones) of a very small percentage of invocations to have a better understanding of the behaviour of your code in production even when there are no errors.
454
+
455
+
Sampling decision happens at the Logger initialization. This means sampling may happen significantly more or less than depending on your traffic patterns, for example a steady low number of invocations and thus few cold starts.
0 commit comments