forked from aws-powertools/powertools-lambda-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathephemeral-attributes.ts
38 lines (27 loc) · 1.04 KB
/
ephemeral-attributes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Populate runtime
require('./../tests/helpers/populateEnvironmentVariables');
// Additional runtime variables
process.env.LOG_LEVEL = 'INFO';
process.env.POWERTOOLS_SERVICE_NAME = 'hello-world';
import * as dummyEvent from '../../../tests/resources/events/custom/hello-world.json';
import { context as dummyContext } from '../../../tests/resources/contexts/hello-world';
import { Handler } from 'aws-lambda';
import { Logger } from '../src';
const logger = new Logger();
const lambdaHandler: Handler = async () => {
const myImportantVariable = {
foo: 'bar'
};
// Pass additional keys and values in single log items
// As second parameter
logger.info('This is a log with an extra variable', { data: myImportantVariable });
// You can also pass multiple parameters
logger.info('This is a log with 2 extra variables',
{ data: myImportantVariable },
{ correlationIds: { myCustomCorrelationId: 'foo-bar-baz' } }
);
return {
foo: 'bar'
};
};
lambdaHandler(dummyEvent, dummyContext, () => console.log('Lambda invoked!'));