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

feat: adds logLevel option, so users can debug lambda functions #286

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

udondan
Copy link
Owner

@udondan udondan commented Mar 22, 2024

No description provided.

Copy link
Contributor

coderabbitai bot commented Mar 22, 2024

Walkthrough

The recent update integrates a logging mechanism across the system, introducing a LogLevel enum to standardize log severity levels and incorporating it into various components. It involves setting up a StandardLogger in the Lambda function based on the log level specified, adding a logLevel property to the KeyPairProps interface with a default warning level, and utilizing the LogLevel in test configurations to ensure consistent logging behavior throughout the application.

Changes

Files Change Summary
lambda/index.ts,
lambda/types.ts
Introduced LogLevel enum and a StandardLogger. The Lambda handler now sets the logger based on the provided log level. Added a LogLevel field to ResourceProperties.
lib/index.ts Added LogLevel to imports/exports and introduced a logLevel property with a default value in KeyPairProps.
test/lib/test-stack.ts Utilized the LogLevel enum to define a log level constant for test configurations.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 539a00a and 5c31cb7.
Files selected for processing (4)
  • lambda/index.ts (2 hunks)
  • lambda/types.ts (2 hunks)
  • lib/index.ts (3 hunks)
  • test/lib/test-stack.ts (3 hunks)
Additional comments: 11
lambda/types.ts (2)
  • 4-11: The LogLevel enum is well-defined and follows common conventions for logging levels. Good use of ESLint directives to handle naming conventions.
  • 34-34: Adding the optional LogLevel field to the ResourceProperties interface is a sensible choice, allowing users to specify their desired logging level if needed.
test/lib/test-stack.ts (3)
  • 11-11: The import of the LogLevel enum is correctly done, ensuring its availability for use within the TestStack class.
  • 18-18: Defining the logLevel constant with LogLevel.DEBUG is appropriate for testing purposes, as it provides detailed logging information.
  • 52-52: The usage of the logLevel constant in the configuration objects for KeyPair instantiation is correctly implemented, ensuring that the desired logging level is applied.

Also applies to: 82-82

lib/index.ts (3)
  • 19-20: The import and re-export of the LogLevel enum are correctly done, making it available both within the module and to external consumers.
  • 144-149: Adding the logLevel property to the KeyPairProps interface with a default value of LogLevel.warn is a sensible choice, ensuring backward compatibility and providing a balanced default logging level.
  • 259-259: Including the logLevel property in the lambdaProperties object for the CustomResource instantiation is correctly implemented, ensuring that the specified logging level is applied.
lambda/index.ts (3)
  • 44-46: The introduction and use of the StandardLogger to dynamically set the logger's level based on the LogLevel provided by the user is correctly implemented. The handling of enum capitalization differences is also appropriately addressed.

Also applies to: 66-73

  • 69-70: The casting approach to handle the mapping between different enum capitalizations for LogLevel is a practical solution to ensure compatibility. While not ideal, it addresses the issue effectively.
  • 58-58: The setting of the logger's level in the handler function based on the LogLevel provided in event.ResourceProperties is correctly implemented, ensuring that the user-specified logging level is applied as intended.

Also applies to: 66-73

@udondan udondan merged commit 6f28d82 into main Mar 22, 2024
3 checks passed
@udondan udondan deleted the logLevel branch March 22, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant