Skip to content

Clean up and enhance logging for messaging and calendar#17498

Merged
charlesBochet merged 2 commits intomainfrom
cleanup-messaging-calendar-logs
Jan 28, 2026
Merged

Clean up and enhance logging for messaging and calendar#17498
charlesBochet merged 2 commits intomainfrom
cleanup-messaging-calendar-logs

Conversation

@neo773
Copy link
Copy Markdown
Member

@neo773 neo773 commented Jan 27, 2026

This PR reduces noise to signal ratio for messaging and calendar logging in production
Impact would be faster queries and debugging

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

This PR improves logging for messaging and calendar import services by implementing a clearer logging strategy that reduces noise while improving debuggability.

Key improvements:

  • Changed routine operational logs from log() to debug() for verbose details like message fetching, folder discovery, and deletion operations
  • Changed actual error logging from log() to error() for proper severity classification
  • Standardized log message format with consistent WorkspaceId: X, MessageChannelId: Y - <action> pattern
  • Enhanced Sentry error context by adding syncStep and throttleFailureCount to exception metadata
  • Removed ID truncation (.slice(0, 5)...) from error messages to provide complete identifiers for debugging
  • Changed exception serialization from full object to exceptionMessage to avoid potential serialization issues while still logging the full exception via logger.error()

The changes improve the signal-to-noise ratio in production logs by moving verbose operational details to debug level while ensuring critical errors remain visible at error level with better context.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it only modifies logging levels and message formatting without changing business logic
  • The changes are purely focused on improving observability without touching any business logic, error handling flow, or data processing. All modifications are either changing logger method names (log->debug/error) or improving log message formatting. No functional behavior is altered.
  • No files require special attention - all changes follow consistent patterns

Important Files Changed

Filename Overview
packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts Improved error handling with better context (syncStep, throttleFailureCount), changed log() to error() for exceptions, and removed ID truncation
packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-fetch-events.service.ts Added structured logging at operation start, improved error messages with consistent WorkspaceId/CalendarChannelId format
packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.ts Improved error context by adding syncStep and throttleFailureCount, removed ID truncation
packages/twenty-server/src/modules/messaging/message-import-manager/services/messaging-message-list-fetch.service.ts Standardized log format with WorkspaceId/MessageChannelId prefix, moved verbose logs to debug()

Sequence Diagram

sequenceDiagram
    participant Client
    participant CalendarFetchEvents as Calendar Fetch Events Service
    participant MessageListFetch as Message List Fetch Service
    participant ExceptionHandler as Exception Handler Service
    participant Logger as Logger (debug/error)
    participant Sentry as Sentry (Exception Tracking)

    Note over Client,Sentry: Before: Verbose log() calls everywhere
    Client->>CalendarFetchEvents: Fetch calendar events
    CalendarFetchEvents->>Logger: log() [routine operation]
    CalendarFetchEvents->>Logger: log() [success message]
    
    Note over Client,Sentry: After: Cleaner logging strategy
    Client->>CalendarFetchEvents: Fetch calendar events
    CalendarFetchEvents->>Logger: log() [operation start with WorkspaceId/CalendarChannelId]
    CalendarFetchEvents->>Logger: debug() [routine details]
    
    alt Error occurs
        CalendarFetchEvents->>ExceptionHandler: Handle error
        ExceptionHandler->>Logger: error() [with full context]
        ExceptionHandler->>Sentry: Capture exception with metadata
        Note over ExceptionHandler,Sentry: Includes: syncStep, throttleFailureCount, full IDs
    end
    
    Client->>MessageListFetch: Fetch message list
    MessageListFetch->>Logger: log() [operation start with WorkspaceId/MessageChannelId]
    MessageListFetch->>Logger: debug() [batch processing details]
    MessageListFetch->>Logger: log() [operation summary]
    
    alt Error occurs
        MessageListFetch->>Logger: error() [structured error message]
        Note over MessageListFetch,Logger: Format: WorkspaceId: X, MessageChannelId: Y - Error details
    end
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 18 files

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:54067

This environment will automatically shut down when the PR is closed or after 5 hours.

@charlesBochet charlesBochet merged commit 7d64ee8 into main Jan 28, 2026
60 checks passed
@charlesBochet charlesBochet deleted the cleanup-messaging-calendar-logs branch January 28, 2026 00:46
@twenty-eng-sync
Copy link
Copy Markdown

Hey @neo773! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫

node failed.

Log

Details
�[31mError: �[39m SyntaxError: Unexpected token 'C', "Contributo"... is not valid JSON
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:4259:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:6882:27)�[39m
�[90m    at readAllBytes (node:internal/deps/undici/undici:5807:13)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)�[39m
danger-results://tmp/danger-results-09edcdf0.json

Generated by 🚫 dangerJS against 1114d9a

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.

2 participants