-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Custom Log Formatter Example disappeared from documentation #1253
Comments
Hi @ValeryShvyndzikau, thanks for reporting this! You're right, there must have been a copy/paste issue and indeed the code snippet got removed (although it's still in the git history). Would you be interested in contributing a PR to bring it back? If yes I'd be happy to help you get it merged quickly. If not, that's alright and we'll put it in the backlog for someone else to pick it up. |
@dreamorosi i could take it if needed. It is a copy paste thing. I would apply the following in import { LogFormatter } from "@aws-lambda-powertools/logger";
import {
LogAttributes,
UnformattedAttributes,
} from "@aws-lambda-powertools/logger/lib/types";
// Replace this line with your own type
type MyCompanyLog = LogAttributes;
class MyCompanyLogFormatter extends LogFormatter {
public formatAttributes(attributes: UnformattedAttributes): MyCompanyLog {
return {
message: attributes.message,
service: attributes.serviceName,
environment: attributes.environment,
awsRegion: attributes.awsRegion,
correlationIds: {
awsRequestId: attributes.lambdaContext?.awsRequestId,
xRayTraceId: attributes.xRayTraceId,
},
lambdaFunction: {
name: attributes.lambdaContext?.functionName,
arn: attributes.lambdaContext?.invokedFunctionArn,
memoryLimitInMB: attributes.lambdaContext?.memoryLimitInMB,
version: attributes.lambdaContext?.functionVersion,
coldStart: attributes.lambdaContext?.coldStart,
},
logLevel: attributes.logLevel,
timestamp: this.formatTimestamp(attributes.timestamp), // You can extend this function
logger: {
sampleRateValue: attributes.sampleRateValue,
},
};
}
}
export { MyCompanyLogFormatter }; |
Great, thank you Niko, that would be the fix. |
@dreamorosi PR for fixing this issue: #1254 . I was around in the repo looking at things , and i saw this issue raised by @ValeryShvyndzikau . That's why i took the action to fix quickly. |
Hi @niko-achilles, no problem, thank you very much for your support and quick fix |
|
What were you searching in the docs?
Hi AWS Lambda Powertools Team
It looks like Custom Log Formatter Example was accidentally removed in the scope of migration to separate files
Here is a link to the corresponding PR https://github.com/awslabs/aws-lambda-powertools-typescript/pull/1230/files#diff-e42af4aee30a146e6e51be432c4a80c93e50d552f7b70403fa301ecf11d355c4
Is this related to an existing documentation section?
No response
How can we improve?
Got a suggestion in mind?
No response
Acknowledgment
The text was updated successfully, but these errors were encountered: