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
Copy file name to clipboardExpand all lines: packages/logger/README.md
+189-45
Original file line number
Diff line number
Diff line change
@@ -4,79 +4,219 @@ Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serve
4
4
5
5
You can use the library in both TypeScript and JavaScript code bases.
6
6
7
-
> Also available in [Python](https://github.com/aws-powertools/powertools-lambda-python), [Java](https://github.com/aws-powertools/powertools-lambda-java), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet).
-[Append additional keys and data](#append-additional-keys-and-data)
18
13
-[Contribute](#contribute)
19
14
-[Roadmap](#roadmap)
20
15
-[Connect](#connect)
21
16
-[How to support Powertools for AWS Lambda (TypeScript)?](#how-to-support-powertools-for-aws-lambda-typescript)
22
17
-[Becoming a reference customer](#becoming-a-reference-customer)
23
18
-[Sharing your work](#sharing-your-work)
24
19
-[Using Lambda Layer](#using-lambda-layer)
25
-
-[Credits](#credits)
26
20
-[License](#license)
27
21
28
-
## Features
22
+
## Intro
29
23
30
-
-**[Tracer](https://docs.powertools.aws.dev/lambda/typescript/latest/core/tracer/)** - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions
31
-
-**[Logger](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/)** - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context
32
-
-**[Metrics](https://docs.powertools.aws.dev/lambda/typescript/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF)
33
-
-**[Parameters](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parameters/)** - High-level functions to retrieve one or more parameters from AWS SSM, Secrets Manager, AppConfig, and DynamoDB
24
+
The Logger utility provides a structured logging experience with additional features tailored for AWS Lambda functions.
34
25
35
-
## Getting started
26
+
## Usage
36
27
37
-
Find the complete project's [documentation here](https://docs.powertools.aws.dev/lambda/typescript).
28
+
To get started, install the library by running:
29
+
30
+
```sh
31
+
npm i @aws-lambda-powertools/logger
32
+
```
38
33
39
-
### Installation
34
+
### Basic usage
40
35
41
-
The Powertools for AWS Lambda (TypeScript) utilities follow a modular approach, similar to the official [AWS SDK v3 for JavaScript](https://github.com/aws/aws-sdk-js-v3).
36
+
Initialize the logger with a service name and log messages:
42
37
43
-
Each TypeScript utility is installed as standalone npm package.
You can find examples of how to use Powertools for AWS Lambda (TypeScript) in the [examples](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/app) directory. The application is a simple REST API that can be deployed via either AWS CDK or AWS SAM.
137
+
### Append additional keys and data
64
138
65
-
### Demo applications
139
+
Append additional keys:
66
140
67
-
The [Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo) shows how to use Powertools for AWS Lambda (TypeScript).
68
-
You can find instructions on how to deploy and load test this application in the [repository](https://github.com/aws-samples/serverless-typescript-demo).
The [AWS Lambda performance tuning](https://github.com/aws-samples/optimizations-for-lambda-functions) repository also uses Powertools for AWS Lambda (TypeScript) as well as demonstrating other performance tuning techniques for Lambda functions written in TypeScript.
144
+
const logger =newLogger();
145
+
146
+
exportconst handler =async (
147
+
event:unknown,
148
+
_context:unknown
149
+
): Promise<unknown> => {
150
+
const myImportantVariable = {
151
+
foo: 'bar',
152
+
};
153
+
154
+
// Log additional data in single log items
155
+
// As second parameter
156
+
logger.info('This is a log with an extra variable', {
157
+
data: myImportantVariable,
158
+
});
159
+
160
+
// You can also pass multiple parameters containing arbitrary objects
If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/CONTRIBUTING.md).
210
+
If you are interested in contributing to this project, please refer to
The roadmap of Powertools for AWS Lambda (TypeScript) is driven by customers’ demand.
79
-
Help us prioritize upcoming functionalities or utilities by [upvoting existing RFCs and feature requests](https://github.com/aws-powertools/powertools-lambda-typescript/issues), or [creating new ones](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new/choose), in this GitHub repository.
216
+
Help us prioritize upcoming functionalities or utilities
217
+
by [upvoting existing RFCs and feature requests](https://github.com/aws-powertools/powertools-lambda-typescript/issues),
218
+
or [creating new ones](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new/choose), in this GitHub
219
+
repository.
80
220
81
221
## Connect
82
222
@@ -87,7 +227,10 @@ Help us prioritize upcoming functionalities or utilities by [upvoting existing R
87
227
88
228
### Becoming a reference customer
89
229
90
-
Knowing which companies are using this library is important to help prioritize the project internally. If your company is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by raising a [Support Lambda Powertools for AWS Lambda (TypeScript) (become a reference)](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new?assignees=&labels=customer-reference&template=support_powertools.yml&title=%5BSupport+Lambda+Powertools%5D%3A+%3Cyour+organization+name%3E) issue.
230
+
Knowing which companies are using this library is important to help prioritize the project internally. If your company
231
+
is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by
232
+
raising a [Support Powertools for AWS Lambda (TypeScript) (become a reference)](https://s12d.com/become-reference-pt-ts)
233
+
issue.
91
234
92
235
The following companies, among others, use Powertools:
93
236
@@ -109,15 +252,16 @@ The following companies, among others, use Powertools:
109
252
110
253
### Sharing your work
111
254
112
-
Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) [here](https://docs.powertools.aws.dev/lambda/typescript/latest/we_made_this).
255
+
Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and
256
+
others. Check out what the community has already shared about Powertools for AWS Lambda (
This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](#lambda-layers), you can add Powertools for AWS Lambda (TypeScript) as a dev dependency (or as part of your virtual env) to not impact the development process.
117
-
118
-
## Credits
119
-
120
-
Credits for the Powertools for AWS Lambda (TypeScript) idea go to [DAZN](https://github.com/getndazn) and their [DAZN Lambda Powertools](https://github.com/getndazn/dazn-lambda-powertools/).
261
+
This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain
262
+
future investments for other Powertools for AWS Lambda languages.
263
+
When [using Layers](https://docs.powertools.aws.dev/lambda/typescript/latest/#lambda-layer), you can add Powertools as a
264
+
dev dependency to not impact the development process.
0 commit comments