Skip to content

Commit 7f4463b

Browse files
committed
chore(logger): set logger metadata as default attributes in examples
1 parent 48f04cd commit 7f4463b

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

packages/logger/examples/custom-logger-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* eslint-disable sort-keys */
21
process.env._X_AMZN_TRACE_ID = 'abcdef123456abcdef123456abcdef123456';
32
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function';
43
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128';
54
process.env.AWS_REGION = 'eu-central-1';
65
process.env.CUSTOM_ENV = 'prod';
76

87
import * as dummyEvent from '../../../tests/resources/events/custom/hello-world.json';
8+
import * as powertool from '../../../package.json';
99
import { CustomConfigService } from './config/CustomConfigService';
1010
import { CustomLogFormatter } from './formatters/CustomLogFormatter';
1111
import { context as dummyContext } from '../../../tests/resources/contexts/hello-world';
@@ -21,8 +21,8 @@ const logger = new Logger({
2121
customAttributes: {
2222
awsAccountId: '123456789012',
2323
logger: {
24-
name: 'aws-lambda-powertools-typescript',
25-
version: 'v0.1.3'
24+
name: powertool.name,
25+
version: powertool.version,
2626
}
2727
}
2828
});

packages/logger/examples/formatters/CustomLogFormatter.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as powertool from '../../package.json';
21
import { LogFormatter } from '../../src/formatter';
32
import { LogAttributes, UnformattedAttributes } from '../../types';
43

@@ -26,8 +25,6 @@ class CustomLogFormatter extends LogFormatter {
2625
logLevel: attributes.logLevel,
2726
timestamp: this.formatTimestamp(attributes.timestamp),
2827
logger: {
29-
name: powertool.name,
30-
version: powertool.version,
3128
level: attributes.logLevel,
3229
sampleRateValue: attributes.sampleRateValue,
3330
},

0 commit comments

Comments
 (0)