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
* import { Logger } from "@aws-lambda-powertools/logger";
73
+
* import { Logger } from '@aws-lambda-powertools/logger';
90
74
* import { LambdaInterface } from '@aws-lambda-powertools/commons';
91
75
*
92
76
* const logger = new Logger();
93
77
*
94
78
* class Lambda implements LambdaInterface {
79
+
*
80
+
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@logger* instead of `@logger.injectLambdaContext`
81
+
*
95
82
* // Decorate your handler class method
96
83
* @logger.injectLambdaContext()
97
84
* public async handler(_event: any, _context: any): Promise<void> {
98
-
* logger.info("This is an INFO log with some context");
85
+
* logger.info('This is an INFO log with some context');
* A middy middleware that adds the current Lambda invocation's context inside all log items.
7
7
*
8
-
* ## Usage
9
-
*
8
+
* Using this middleware on your handler function will automatically add context information to logs, as well as optionally log the event and clear attributes set during the invocation.
9
+
*
10
10
* @example
11
11
* ```typescript
12
-
* import { Logger, injectLambdaContext } from "@aws-lambda-powertools/logger";
13
-
*
12
+
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger';
* If you are used to TypeScript Class usage to encapsulate your Lambda handler you can leverage the [@metrics.logMetrics()](./_aws_lambda_powertools_metrics.Metrics.html#logMetrics) decorator to automatically:
37
-
* * create cold start metric
59
+
* * capture a `ColdStart` metric
38
60
* * flush buffered metrics
39
61
* * throw on empty metrics
40
62
*
41
63
* @example
42
64
*
43
65
* ```typescript
44
66
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
45
-
* import { Callback, Context } from 'aws-lambda';
67
+
* import { LambdaInterface } from '@aws-lambda-powertools/commons';
46
68
*
47
-
* const metrics = new Metrics({ namespace:'MyService', serviceName:'withDecorator' });
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/39371 and might show as *@metrics* instead of `@metrics.logMetrics`
73
+
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@metrics* instead of `@metrics.logMetrics`
0 commit comments