Skip to content
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

Closed
1 task done
ValeryShvyndzikau opened this issue Jan 17, 2023 · 6 comments · Fixed by #1254
Closed
1 task done

Docs: Custom Log Formatter Example disappeared from documentation #1253

ValeryShvyndzikau opened this issue Jan 17, 2023 · 6 comments · Fixed by #1254
Assignees
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation

Comments

@ValeryShvyndzikau
Copy link

ValeryShvyndzikau commented Jan 17, 2023

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

logger_documentation_003
logger_documentation_002
logger_documentation_001

logger_documentation_004

Is this related to an existing documentation section?

No response

How can we improve?

Get back Custom Formatter Example

Got a suggestion in mind?

No response

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.
@ValeryShvyndzikau ValeryShvyndzikau added documentation Improvements or additions to documentation triage This item has not been triaged by a maintainer, please wait labels Jan 17, 2023
@ValeryShvyndzikau ValeryShvyndzikau changed the title Docs: Custom Log Formatter Example disappeared form documentation Docs: Custom Log Formatter Example disappeared from documentation Jan 17, 2023
@dreamorosi
Copy link
Contributor

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 dreamorosi added confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Jan 17, 2023
@niko-achilles
Copy link
Contributor

@dreamorosi i could take it if needed. It is a copy paste thing.

I would apply the following in bringYourOwnFormatterClass.ts code snippet that is extracted in docs/snippets/logger .

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 };

@dreamorosi
Copy link
Contributor

Great, thank you Niko, that would be the fix.

@niko-achilles
Copy link
Contributor

@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.
Nice catch by @ValeryShvyndzikau .

@ValeryShvyndzikau
Copy link
Author

Hi @niko-achilles, no problem, thank you very much for your support and quick fix

@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed confirmed The scope is clear, ready for implementation labels Jan 17, 2023
@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Jan 17, 2023
@dreamorosi dreamorosi removed the pending-release This item has been merged and will be released soon label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants