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: add debug logs in api #294

Merged
12 commits merged into from
Jul 30, 2024
Merged

feat: add debug logs in api #294

12 commits merged into from
Jul 30, 2024

Conversation

kshitij-k-osmosys
Copy link
Contributor

@kshitij-k-osmosys kshitij-k-osmosys commented Jul 29, 2024

API PR Checklist

Pre-requisites

  • I have gone through the Contributing guidelines for Submitting a Pull Request (PR) and ensured that this is not a duplicate PR.
  • I have performed preliminary testing using the test suite to ensure that any existing features are not impacted and any new features are working as expected.
  • I have updated the required api docs as applicable.
  • I have added/updated test cases to the test suite as applicable

PR Details

PR details have been updated as per the given format (see below)

  • PR title adheres to the format specified in guidelines (e.g., feat: add admin login endpoint)
  • Description has been added
  • Related changes have been added (optional)
  • Screenshots have been added (optional)
  • Query request and response examples have been added (as applicable, in case added or updated)
  • Documentation changes have been listed (as applicable)
  • Test suite output is added (as applicable)
  • Pending actions have been added (optional)
  • Any other additional notes have been added (optional)

Additional Information

  • Appropriate label(s) have been added (ready for review should be added if the PR is ready to be reviewed)
  • Assignee(s) and reviewer(s) have been added (optional)

Description:

Add debug logs wherever there is another method call or values fetched/changed
Allow user to set log level from env file

Related changes:

NA

Screenshots:

NA

Query request and response:

NA

Documentation changes:

NA

Test suite output:

NA

Pending actions:

NA

Additional notes:

NA

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration parameter for logging level, enhancing application logging control.
  • Improvements

    • Enhanced logging functionality across multiple services to provide better visibility on request processing, validation, and notification workflows, facilitating easier tracking of data flow and identification of potential issues.

Copy link

coderabbitai bot commented Jul 29, 2024

Warning

Rate limit exceeded

@kshitij-k-osmosys has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 34 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between affbe44 and ae53847.

Walkthrough

The changes enhance the application's logging capabilities by introducing a new configuration parameter, LOG_LEVEL, and integrating comprehensive logging throughout various services and decorators. This improvement allows for detailed debug logging across workflows, enhancing monitoring and troubleshooting from validation processes to notification handling, thus providing clearer insights into application behavior.

Changes

Files/Directories Change Summary
apps/api/.env.example Added LOG_LEVEL=info for configurable logging level.
apps/api/src/common/decorators/* Integrated Logger for improved validation logging in decorators.
apps/api/src/common/guards/api-key/*.guard.ts Enhanced validateRequest method with detailed logging information.
apps/api/src/jobs/consumers/notifications/*.consumer.ts Added debug logging for the notification processing workflow.
apps/api/src/jobs/producers/notifications/*.job.producer.ts Introduced logging for the notification queueing process.
apps/api/src/modules/notifications/*.service.ts Logged notification processing details to improve observability.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant Service
    participant Logger
    participant Queue

    Client->>Controller: Send Notification Data
    Controller->>Service: Create Notification
    Service->>Logger: Log Incoming Data
    Service->>Queue: Add Notification to Queue
    Queue->>Logger: Log Queueing Process
    Queue->>Service: Notify Success
    Service-->>Controller: Response
    Controller-->>Client: Send Response
Loading

🐰 In the code so bright,
A logging delight!
With levels to set,
For no bug we fret.
Each hop brings cheer,
As logs draw near! 🌟


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 testing code 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 testing code 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 testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kshitij-k-osmosys kshitij-k-osmosys changed the title Feat/debug logs feat: add debug logs Jul 30, 2024
@kshitij-k-osmosys kshitij-k-osmosys marked this pull request as ready for review July 30, 2024 04:17
@kshitij-k-osmosys kshitij-k-osmosys self-assigned this Jul 30, 2024
@kshitij-k-osmosys kshitij-k-osmosys requested a review from a user July 30, 2024 04:18
Copy link

@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.

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (20)
apps/api/src/common/guards/api-key/api-key.guard.ts (14)

35-36: Add context to log messages.

The log messages are clear but can be enhanced by including additional context such as the request ID or user ID for better traceability.

- this.logger.debug('HTTP Request was issued');
+ this.logger.debug(`HTTP Request was issued for request ID: ${request.id}`);

53-54: Add context to log messages.

Similar to the HTTP request log messages, include additional context such as the request ID or user ID for better traceability.

- this.logger.debug('GraphQL Request was issued');
+ this.logger.debug(`GraphQL Request was issued for request ID: ${req.id}`);

82-82: Improve log message clarity.

The log message can be improved by providing more context about the server API key being fetched.

- this.logger.debug(`Fetching Server API Key from request token: ${JSON.stringify(apiKeyEntry)}`);
+ this.logger.debug(`Fetched Server API Key entry: ${JSON.stringify(apiKeyEntry)}`);

91-91: Improve log message clarity.

The log message can be improved by providing more context about the provider entry being fetched.

- this.logger.debug(`Fetching provider by request providerId: ${JSON.stringify(providerEntry)}`);
+ this.logger.debug(`Fetched provider entry for providerId: ${requestProviderId}: ${JSON.stringify(providerEntry)}`);

106-108: Improve log message clarity.

The log message can be improved by providing more context about the application ID being set.

- this.logger.debug(`Set correct ApplicationId for request: ${JSON.stringify(inputApplicationId)}`);
+ this.logger.debug(`Set correct ApplicationId for request with providerId: ${requestProviderId}: ${JSON.stringify(inputApplicationId)}`);

116-118: Improve log message clarity.

The log message can be improved by providing more context about the validation result.

- this.logger.debug('Requested providerId is valid. The applicationId for Server Key and Provider match. Valid Request.');
+ this.logger.debug(`Requested providerId: ${requestProviderId} is valid. The applicationId for Server Key and Provider match. Valid Request.`);

82-82: Improve log message clarity.

The log message can be improved by providing more context about the server API key being fetched.

- this.logger.debug(`Fetching Server API Key from request token: ${JSON.stringify(apiKeyEntry)}`);
+ this.logger.debug(`Fetched Server API Key entry: ${JSON.stringify(apiKeyEntry)}`);

91-91: Improve log message clarity.

The log message can be improved by providing more context about the provider entry being fetched.

- this.logger.debug(`Fetching provider by request providerId: ${JSON.stringify(providerEntry)}`);
+ this.logger.debug(`Fetched provider entry for providerId: ${requestProviderId}: ${JSON.stringify(providerEntry)}`);

106-108: Improve log message clarity.

The log message can be improved by providing more context about the application ID being set.

- this.logger.debug(`Set correct ApplicationId for request: ${JSON.stringify(inputApplicationId)}`);
+ this.logger.debug(`Set correct ApplicationId for request with providerId: ${requestProviderId}: ${JSON.stringify(inputApplicationId)}`);

116-118: Improve log message clarity.

The log message can be improved by providing more context about the validation result.

- this.logger.debug('Requested providerId is valid. The applicationId for Server Key and Provider match. Valid Request.');
+ this.logger.debug(`Requested providerId: ${requestProviderId} is valid. The applicationId for Server Key and Provider match. Valid Request.`);

82-82: Improve log message clarity.

The log message can be improved by providing more context about the server API key being fetched.

- this.logger.debug(`Fetching Server API Key from request token: ${JSON.stringify(apiKeyEntry)}`);
+ this.logger.debug(`Fetched Server API Key entry: ${JSON.stringify(apiKeyEntry)}`);

91-91: Improve log message clarity.

The log message can be improved by providing more context about the provider entry being fetched.

- this.logger.debug(`Fetching provider by request providerId: ${JSON.stringify(providerEntry)}`);
+ this.logger.debug(`Fetched provider entry for providerId: ${requestProviderId}: ${JSON.stringify(providerEntry)}`);

106-108: Improve log message clarity.

The log message can be improved by providing more context about the application ID being set.

- this.logger.debug(`Set correct ApplicationId for request: ${JSON.stringify(inputApplicationId)}`);
+ this.logger.debug(`Set correct ApplicationId for request with providerId: ${requestProviderId}: ${JSON.stringify(inputApplicationId)}`);

116-118: Improve log message clarity.

The log message can be improved by providing more context about the validation result.

- this.logger.debug('Requested providerId is valid. The applicationId for Server Key and Provider match. Valid Request.');
+ this.logger.debug(`Requested providerId: ${requestProviderId} is valid. The applicationId for Server Key and Provider match. Valid Request.`);
apps/api/src/common/decorators/is-data-valid.decorator.ts (1)

42-44: Improve log message clarity.

The log message can be improved by providing more context about the channel type being fetched.

- this.logger.debug(`Fetched channel type: ${channelTypeFromProviderId} from provider Id: ${object.providerId}`);
+ this.logger.debug(`Fetched channel type: ${channelTypeFromProviderId} for provider Id: ${object.providerId}`);
apps/api/src/jobs/consumers/notifications/notification.consumer.ts (5)

42-44: Improve log message clarity.

The log message can be improved by providing more context about the notification ID and channel type.

- this.logger.debug(`Channel type: ${notification.channelType} is included in skip queue. Provider confirmation skipped for notification id ${notification.id}`);
+ this.logger.debug(`Channel type: ${notification.channelType} is included in skip queue. Provider confirmation skipped for notification ID: ${notification.id}`);

48-50: Improve log message clarity.

The log message can be improved by providing more context about the notification ID.

- this.logger.debug(`Notification id ${notification.id} is awaiting confirmation from provider`);
+ this.logger.debug(`Notification ID: ${notification.id} is awaiting confirmation from provider`);

54-54: Improve log message clarity.

The log message can be improved by providing more context about the notification ID.

- this.logger.debug(`Updating result of notification with id ${notification.id}`);
+ this.logger.debug(`Updating result of notification with ID: ${notification.id}`);

58-60: Fix typo in log message.

There is a typo in the log message ("occurred" is misspelled as "occured").

- this.logger.debug(`Some error occured while sendiing Notification with ID ${notification.id}. Retry Count ${notification.retryCount}/${this.maxRetryCount}. Sending notification again`);
+ this.logger.debug(`Some error occurred while sending Notification with ID: ${notification.id}. Retry Count: ${notification.retryCount}/${this.maxRetryCount}. Sending notification again`);

132-132: Improve log message clarity.

The log message can be improved by providing more context about the notification ID.

- this.logger.debug('Saving notification data in DB');
+ this.logger.debug(`Saving notification data in DB for notification ID: ${notification.id}`);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1a398c7 and 7ea564a.

Files selected for processing (19)
  • apps/api/.env.example (1 hunks)
  • apps/api/src/common/decorators/is-data-valid.decorator.ts (2 hunks)
  • apps/api/src/common/guards/api-key/api-key.guard.ts (6 hunks)
  • apps/api/src/config/logger.config.ts (2 hunks)
  • apps/api/src/jobs/consumers/notifications/notification.consumer.ts (3 hunks)
  • apps/api/src/jobs/producers/notifications/notifications.job.producer.ts (1 hunks)
  • apps/api/src/modules/notifications/notifications.controller.ts (1 hunks)
  • apps/api/src/modules/notifications/notifications.service.ts (1 hunks)
  • apps/api/src/modules/notifications/queues/queue.service.ts (2 hunks)
  • apps/api/src/modules/providers/mailgun/mailgun.service.ts (6 hunks)
  • apps/api/src/modules/providers/push-sns/push-sns.service.ts (3 hunks)
  • apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.service.ts (3 hunks)
  • apps/api/src/modules/providers/sms-plivo/sms-plivo.service.ts (4 hunks)
  • apps/api/src/modules/providers/sms-twilio/sms-twilio.service.ts (4 hunks)
  • apps/api/src/modules/providers/smtp/smtp.service.ts (2 hunks)
  • apps/api/src/modules/providers/vc-twilio/vc-twilio.service.ts (4 hunks)
  • apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.service.ts (4 hunks)
  • apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts (4 hunks)
  • apps/api/src/modules/providers/wa360dialog/wa360dialog.service.ts (3 hunks)
Files skipped from review due to trivial changes (3)
  • apps/api/.env.example
  • apps/api/src/modules/notifications/notifications.controller.ts
  • apps/api/src/modules/notifications/notifications.service.ts
Additional context used
Learnings (3)
apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.service.ts (1)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#263
File: apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts:0-0
Timestamp: 2024-06-28T05:13:41.818Z
Learning: LakshayaT has implemented error handling in the `sendMessage` method of `WaTwilioService` as suggested by CodeRabbit, ensuring that errors are not suppressed and are properly logged.
apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts (1)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#263
File: apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts:0-0
Timestamp: 2024-06-28T05:13:41.818Z
Learning: LakshayaT has implemented error handling in the `sendMessage` method of `WaTwilioService` as suggested by CodeRabbit, ensuring that errors are not suppressed and are properly logged.
apps/api/src/jobs/consumers/notifications/notification.consumer.ts (1)
Learnt from: LakshayaT
PR: OsmosysSoftware/osmo-x#263
File: apps/api/src/jobs/consumers/notifications/notification.consumer.ts:36-40
Timestamp: 2024-07-03T05:58:54.296Z
Learning: When reviewing retry mechanisms and delivery status updates, if the error object is already being logged, additional log messages for retry count and status might be redundant.
Biome
apps/api/src/common/guards/api-key/api-key.guard.ts

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (51)
apps/api/src/modules/providers/smtp/smtp.service.ts (2)

13-13: LGTM! Debug log added for SMTP transport assignment.

The debug log statement provides useful information about the start of the SMTP transport assignment.


30-30: LGTM! Debug log added for sending SMTP email.

The debug log statement provides useful information about the initiation of the email sending process.

apps/api/src/modules/providers/push-sns/push-sns.service.ts (2)

18-18: LGTM! Debug log added for SNS client assignment.

The debug log statement provides useful information about the start of the SNS client assignment.


38-38: LGTM! Debug log added for sending SNS push notification.

The debug log statement provides useful information about the initiation of the push notification sending process.

apps/api/src/jobs/producers/notifications/notifications.job.producer.ts (2)

17-19: LGTM! Debug log added for provider fetching.

The debug log statement provides useful information about the fetched provider and the associated notification.


25-25: LGTM! Debug log added for notification queuing.

The debug log statement provides useful information about the notification being added to the queue.

apps/api/src/config/logger.config.ts (3)

6-6: Import statement for ConfigService looks good.

The import statement for ConfigService is correctly added.


8-8: Instance creation for ConfigService looks good.

The instance of ConfigService is correctly created.


63-63: Dynamic logger level configuration looks good.

The logger level is dynamically set using the LOG_LEVEL configuration with a default value of 'info'.

apps/api/src/modules/providers/wa360dialog/wa360dialog.service.ts (4)

2-2: Import statement for Logger looks good.

The import statement for Logger is correctly added.


53-53: Constructor changes for Logger injection look good.

The Logger is correctly injected into the constructor of Wa360dialogService.


57-57: Debug log statement in assignWA360Values looks good.

The debug log statement at the beginning of the method indicates the start of the value assignment process.


69-69: Debug log statement in sendMessage looks good.

The debug log statement before sending the HTTP request indicates that the SMS is being dispatched.

apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.service.ts (4)

2-2: Import statement for Logger looks good.

The import statement for Logger is correctly added.


37-37: Constructor changes for Logger injection look good.

The Logger is correctly injected into the constructor of SmsKapsystemService.


41-41: Debug log statement in assignKAPSystemValues looks good.

The debug log statement at the beginning of the method indicates the start of the value assignment process.


71-71: Debug log statement in sendMessage looks good.

The debug log statement before sending the HTTP request indicates that the SMS is being dispatched.

apps/api/src/modules/providers/sms-twilio/sms-twilio.service.ts (3)

41-41: LGTM!

The debug log statement provides useful information about the start of the transport assignment process.


53-53: LGTM!

The debug log statement provides useful information about the SMS sending process.


64-67: LGTM!

The debug log statements provide useful information about the delivery status fetching process and the retrieved status message.

apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.service.ts (3)

43-43: LGTM!

The debug log statement provides useful information about the start of the transport assignment process.


55-55: LGTM!

The debug log statement provides useful information about the WhatsApp Business message-sending process.


67-70: LGTM!

The debug log statements provide useful information about the delivery status fetching process and the retrieved status message.

apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts (3)

41-41: LGTM!

The debug log statement provides useful information about the start of the transport assignment process.


59-59: LGTM!

The debug log statement provides useful information about the WhatsApp message-sending process.


68-71: LGTM!

The debug log statements provide useful information about the delivery status fetching process and the retrieved status message.

apps/api/src/modules/providers/sms-plivo/sms-plivo.service.ts (4)

1-1: LGTM! Logger instance added.

The Logger instance is correctly imported and initialized.

Also applies to: 52-52


57-57: LGTM! Debug log added to assignTransport.

The debug log statement is correctly placed and provides meaningful information.


70-70: LGTM! Debug log added to sendMessage.

The debug log statement is correctly placed and provides meaningful information.


87-87: LGTM! Debug logs added to getDeliveryStatus.

The debug log statements are correctly placed and provide meaningful information.

Also applies to: 90-90

apps/api/src/modules/providers/mailgun/mailgun.service.ts (6)

1-1: LGTM! Logger instance added.

The Logger instance is correctly imported and initialized.

Also applies to: 21-21


28-28: LGTM! Debug log added to assignClient.

The debug log statement is correctly placed and provides meaningful information.


44-44: LGTM! Debug log added to sendEmail.

The debug log statement is correctly placed and provides meaningful information.


54-54: LGTM! Debug log added to formatNotificationData.

The debug log statement is correctly placed and provides meaningful information.


73-73: LGTM! Debug log added to formatAttachments.

The debug log statement is correctly placed and provides meaningful information.


101-101: LGTM! Debug logs added to getDeliveryStatus.

The debug log statements are correctly placed and provide meaningful information.

Also applies to: 106-106

apps/api/src/modules/providers/vc-twilio/vc-twilio.service.ts (4)

1-1: LGTM! Logger instance added.

The Logger instance is correctly imported and initialized.

Also applies to: 87-87


92-92: LGTM! Debug log added to assignTransport.

The debug log statement is correctly placed and provides meaningful information.


151-151: LGTM! Debug log added to sendVoiceCall.

The debug log statement is correctly placed and provides meaningful information.


161-161: LGTM! Debug logs added to getDeliveryStatus.

The debug log statements are correctly placed and provide meaningful information.

Also applies to: 164-164

apps/api/src/common/guards/api-key/api-key.guard.ts (4)

29-31: Add logging level configuration.

The debug log statement is useful for tracing the request validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?


71-71: Add logging level configuration.

The debug log statement is useful for tracing the API key validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?


71-71: Add logging level configuration.

The debug log statement is useful for tracing the API key validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?


71-71: Add logging level configuration.

The debug log statement is useful for tracing the API key validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?

apps/api/src/common/decorators/is-data-valid.decorator.ts (3)

29-32: Ensure logger instance is properly configured.

The addition of the Logger instance is appropriate for enhanced logging. Ensure that the logger is properly configured to respect the log level settings.

Is the Logger instance properly configured to respect the LOG_LEVEL settings?


35-35: Add logging level configuration.

The debug log statement is useful for tracing the validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?


50-50: Add logging level configuration.

The debug log statement is useful for tracing the validation process. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?

apps/api/src/jobs/consumers/notifications/notification.consumer.ts (2)

36-38: Add logging level configuration.

The debug log statement is useful for tracing the notification processing workflow. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?


89-91: Add logging level configuration.

The debug log statement is useful for tracing the notification processing workflow. Ensure that the logging level is appropriately configured to avoid excessive logging in production.

Is the LOG_LEVEL configuration properly set in the environment file?

apps/api/src/modules/notifications/queues/queue.service.ts (2)

75-75: Good addition: Debug log statement.

The debug log statement helps in tracking the initiation of the queue creation process.


88-90: Good addition: Debug log statement.

The debug log statement helps in tracking the details of the job being processed.

apps/api/src/common/guards/api-key/api-key.guard.ts Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ea564a and e990ec5.

Files selected for processing (1)
  • apps/api/src/common/guards/api-key/api-key.guard.ts (6 hunks)
Additional context used
Biome
apps/api/src/common/guards/api-key/api-key.guard.ts

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (7)
apps/api/src/common/guards/api-key/api-key.guard.ts (7)

29-31: LGTM! The log statement enhances observability.

The debug log statement indicating the start of request validation is clear and useful for debugging.


35-35: LGTM! Efficient logging.

Combining the log statements for fetching the request header and provider ID reduces the number of log entries.


52-54: LGTM! Efficient logging.

Combining the log statements for fetching the request header and provider ID for GraphQL reduces the number of log entries.


71-71: LGTM! The log statement enhances observability.

The debug log statement indicating the start of validateApiKeyHeader is clear and useful for debugging.


82-82: LGTM! The log statement enhances observability.

The debug log statement for fetching the server API key from the request token is clear and useful for debugging.


91-91: LGTM! The log statement enhances observability.

The debug log statement for fetching the provider by request provider ID is clear and useful for debugging.


37-37: Remove redundant log statement.

The log statement for fetching the provider ID is redundant as it is already included in the previous log statement.

- this.logger.debug('Fetching provider Id');

Likely invalid or redundant comment.

apps/api/src/common/guards/api-key/api-key.guard.ts Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e990ec5 and 81e62bc.

Files selected for processing (1)
  • apps/api/src/modules/providers/providers.service.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/api/src/modules/providers/providers.service.ts

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 81e62bc and 8d8991b.

Files selected for processing (11)
  • apps/api/src/jobs/producers/notifications/notifications.job.producer.ts (1 hunks)
  • apps/api/src/modules/providers/mailgun/mailgun.module.ts (1 hunks)
  • apps/api/src/modules/providers/push-sns/push-sns.module.ts (1 hunks)
  • apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.module.ts (2 hunks)
  • apps/api/src/modules/providers/sms-plivo/sms-plivo.module.ts (1 hunks)
  • apps/api/src/modules/providers/sms-twilio/sms-twilio.module.ts (1 hunks)
  • apps/api/src/modules/providers/smtp/smtp.module.ts (1 hunks)
  • apps/api/src/modules/providers/vc-twilio/vc-twilio.module.ts (1 hunks)
  • apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.module.ts (1 hunks)
  • apps/api/src/modules/providers/wa-twilio/wa-twilio.module.ts (1 hunks)
  • apps/api/src/modules/providers/wa360dialog/wa360dialog.module.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/jobs/producers/notifications/notifications.job.producer.ts
Additional comments not posted (14)
apps/api/src/modules/providers/vc-twilio/vc-twilio.module.ts (1)

1-1: Add Logger service to providers array.

The addition of the Logger service to the providers array enhances the module's logging capabilities, aligning with the PR objective.

Also applies to: 8-8

apps/api/src/modules/providers/smtp/smtp.module.ts (1)

1-1: Add Logger service to providers array.

The addition of the Logger service to the providers array enhances the module's logging capabilities, aligning with the PR objective.

Also applies to: 9-9

apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.module.ts (1)

1-1: Add Logger service to providers array.

The addition of the Logger service to the providers array enhances the module's logging capabilities, aligning with the PR objective.

Also applies to: 8-8

apps/api/src/modules/providers/mailgun/mailgun.module.ts (1)

1-1: LGTM! Ensure proper usage of the Logger service.

The addition of the Logger service to the providers array is a good practice for enhancing logging capabilities. Make sure that the Logger service is correctly utilized within the MailgunModule.

Also applies to: 9-9

apps/api/src/modules/providers/push-sns/push-sns.module.ts (1)

1-1: LGTM! Ensure proper usage of the Logger service.

The addition of the Logger service to the providers array is a good practice for enhancing logging capabilities. Make sure that the Logger service is correctly utilized within the PushSnsModule.

Also applies to: 9-9

apps/api/src/modules/providers/sms-plivo/sms-plivo.module.ts (1)

1-1: LGTM! Ensure proper usage of the Logger service.

The addition of the Logger service to the providers array is a good practice for enhancing logging capabilities. Make sure that the Logger service is correctly utilized within the SmsPlivoModule.

Also applies to: 9-9

apps/api/src/modules/providers/wa-twilio/wa-twilio.module.ts (2)

1-1: Importing Logger from @nestjs/common

The import statement for Logger from @nestjs/common is correctly added.


9-9: Adding Logger to the providers array

The Logger is correctly added to the providers array, enabling logging capabilities within the module.

To ensure the Logger is effectively utilized, verify its usage in the services within this module.

Verification successful

Logger is effectively utilized in the WaTwilioService.

The Logger is imported and used within the wa-twilio.service.ts file, confirming its role in logging activities within the module.

  • wa-twilio.service.ts: Logger is declared as a private member and used in the assignTransport method for logging.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `WaTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type python -A 5 'Logger' apps/api/src/modules/providers/wa-twilio/

Length of output: 103


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `WaTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type typescript -A 5 'Logger' apps/api/src/modules/providers/wa-twilio/

Length of output: 111


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `WaTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg -t ts -A 5 'Logger' apps/api/src/modules/providers/wa-twilio/

Length of output: 2237

apps/api/src/modules/providers/sms-twilio/sms-twilio.module.ts (2)

1-1: Importing Logger from @nestjs/common

The import statement for Logger from @nestjs/common is correctly added.


9-9: Adding Logger to the providers array

The Logger is correctly added to the providers array, enabling logging capabilities within the module.

To ensure the Logger is effectively utilized, verify its usage in the services within this module.

Verification successful

Logger is effectively utilized in SmsTwilioService

The Logger is not only imported and declared in sms-twilio.service.ts, but it is also actively used for logging within the service.

  • sms-twilio.service.ts:
    • this.logger.debug('Started assigning transport for SMS Twilio');
    • this.logger.debug('Sending Twilio SMS');
    • this.logger.debug('Fetching delivery status from twilio SMS');
    • this.logger.debug(\Delivery status: ${message}`);`
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `SmsTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type python -A 5 'Logger' apps/api/src/modules/providers/sms-twilio/

Length of output: 104


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `SmsTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type typescript -A 5 'Logger' apps/api/src/modules/providers/sms-twilio/

Length of output: 112


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `SmsTwilioModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg 'Logger' apps/api/src/modules/providers/sms-twilio/

Length of output: 495


Script:

#!/bin/bash
# Description: Verify the usage of `this.logger` in the SmsTwilioService.

# Test: Search for the usage of `this.logger` in the SmsTwilioService. Expect: Logger is used for logging.
rg 'this.logger' apps/api/src/modules/providers/sms-twilio/sms-twilio.service.ts

Length of output: 319

apps/api/src/modules/providers/wa360dialog/wa360dialog.module.ts (2)

1-1: Importing Logger from @nestjs/common

The import statement for Logger from @nestjs/common is correctly added.


10-10: Adding Logger to the providers array

The Logger is correctly added to the providers array, enabling logging capabilities within the module.

To ensure the Logger is effectively utilized, verify its usage in the services within this module.

Verification successful

Logger usage verified

The Logger is correctly utilized in the wa360dialog.service.ts file within the assignWA360Values method, confirming its effective usage in the services of the Wa360dialogModule.

  • wa360dialog.service.ts:
    • import { Injectable, Logger } from '@nestjs/common';
    • private logger: Logger,
    • this.logger.debug('Started assigning 360Dialog Whatsapp values');
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `Wa360dialogModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type python -A 5 'Logger' apps/api/src/modules/providers/wa360dialog/

Length of output: 105


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in the services within the `Wa360dialogModule`.

# Test: Search for the usage of `Logger` in the services. Expect: Logger is used for logging.
rg --type ts -A 5 'Logger' apps/api/src/modules/providers/wa360dialog/

Length of output: 2388

apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.module.ts (2)

1-1: Import statement change is correct.

The import of Logger from @nestjs/common is appropriate for adding logging capabilities.


10-10: Adding Logger to providers array is correct.

Including Logger in the providers array enables logging within the module.

Verify the usage of Logger in the SmsKapsystemService.

Verification successful

Adding Logger to providers array is correct.

The Logger is properly set up and used within the SmsKapsystemService class for logging purposes.

  • SmsKapsystemService contains logging statements using this.logger.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in `SmsKapsystemService`.

# Test: Search for the usage of `Logger` in `SmsKapsystemService`. Expect: Proper logging statements.
rg --type python -A 5 $'SmsKapsystemService'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in `SmsKapsystemService`.

# Test: Search for the usage of `Logger` in `SmsKapsystemService`. Expect: Proper logging statements.
rg --type ts -A 5 'Logger' --files-with-matches | xargs rg -A 5 'SmsKapsystemService'

Length of output: 1710


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in `SmsKapsystemService`.

# Test: Search for the usage of `Logger` in `SmsKapsystemService`. Expect: Proper logging statements.
rg 'Logger' apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.service.ts

Length of output: 162


Script:

#!/bin/bash
# Description: Verify the usage of `Logger` in `SmsKapsystemService`.

# Test: Search for the usage of `this.logger` in `SmsKapsystemService`. Expect: Proper logging statements.
rg 'this.logger' apps/api/src/modules/providers/sms-kapsystem/sms-kapsystem.service.ts

Length of output: 195

@kshitij-k-osmosys kshitij-k-osmosys marked this pull request as draft July 30, 2024 08:25
@kshitij-k-osmosys kshitij-k-osmosys marked this pull request as ready for review July 30, 2024 08:34
Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d8991b and bb2fa78.

Files selected for processing (8)
  • apps/api/src/modules/providers/mailgun/mailgun.service.ts (6 hunks)
  • apps/api/src/modules/providers/push-sns/push-sns.service.ts (3 hunks)
  • apps/api/src/modules/providers/sms-plivo/sms-plivo.service.ts (4 hunks)
  • apps/api/src/modules/providers/sms-twilio/sms-twilio.service.ts (4 hunks)
  • apps/api/src/modules/providers/smtp/smtp.service.ts (2 hunks)
  • apps/api/src/modules/providers/vc-twilio/vc-twilio.service.ts (4 hunks)
  • apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.service.ts (4 hunks)
  • apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts (4 hunks)
Files skipped from review due to trivial changes (1)
  • apps/api/src/modules/providers/sms-twilio/sms-twilio.service.ts
Files skipped from review as they are similar to previous changes (7)
  • apps/api/src/modules/providers/mailgun/mailgun.service.ts
  • apps/api/src/modules/providers/push-sns/push-sns.service.ts
  • apps/api/src/modules/providers/sms-plivo/sms-plivo.service.ts
  • apps/api/src/modules/providers/smtp/smtp.service.ts
  • apps/api/src/modules/providers/vc-twilio/vc-twilio.service.ts
  • apps/api/src/modules/providers/wa-twilio-business/wa-twilio-business.service.ts
  • apps/api/src/modules/providers/wa-twilio/wa-twilio.service.ts

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bb2fa78 and a7c201a.

Files selected for processing (4)
  • apps/api/src/common/guards/api-key/api-key.guard.ts (6 hunks)
  • apps/api/src/jobs/consumers/notifications/notification.consumer.ts (4 hunks)
  • apps/api/src/jobs/producers/notifications/notifications.job.producer.ts (1 hunks)
  • apps/api/src/modules/notifications/notifications.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (3)
  • apps/api/src/jobs/consumers/notifications/notification.consumer.ts
  • apps/api/src/jobs/producers/notifications/notifications.job.producer.ts
  • apps/api/src/modules/notifications/notifications.service.ts
Additional context used
Biome
apps/api/src/common/guards/api-key/api-key.guard.ts

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (8)
apps/api/src/common/guards/api-key/api-key.guard.ts (8)

29-31: LGTM!

The debug log statement provides useful information for tracking the start of request validation.


35-35: LGTM!

The combined debug log statement improves clarity by reducing the number of log entries.


37-37: Redundant log statement removed.

The redundant log statement for fetching the provider ID has been correctly removed.


52-54: LGTM!

The debug log statement provides useful information for tracking the request header and provider ID in GraphQL requests.


56-56: Redundant log statement removed.

The redundant log statement for fetching the provider ID in GraphQL requests has been correctly removed.


71-71: LGTM!

The debug log statement provides useful information for tracking the start of the validateApiKeyHeader method.


82-82: LGTM!

The debug log statement provides useful information for tracking the fetching of the server API key from the request token.


91-93: LGTM!

The debug log statement provides useful information for tracking the fetching of the provider entry from the database.

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a7c201a and affbe44.

Files selected for processing (2)
  • apps/api/src/jobs/consumers/notifications/notification.consumer.ts (4 hunks)
  • apps/api/src/modules/notifications/notifications.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/api/src/jobs/consumers/notifications/notification.consumer.ts
  • apps/api/src/modules/notifications/notifications.service.ts

@ghost ghost changed the title feat: add debug logs feat: add debug logs in api Jul 30, 2024
@ghost ghost merged commit bbae98b into main Jul 30, 2024
6 checks passed
@ghost ghost deleted the feat/debug-logs branch July 30, 2024 11:30
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant