Skip to content

Conversation

@Sanskriti0805
Copy link

@Sanskriti0805 Sanskriti0805 commented Dec 22, 2025

Fix: Remove Duplicate Logger Initialization in images.py

Description
Fixes duplicate logger initialization in backend/app/utils/images.py that was causing the custom configured logger to be overwritten by a standard Python logger.

Changes Made

  • Removed duplicate logger initialization on line 29 (logger = logging.getLogger(__name__))
  • Removed unused import logging statement
  • Kept only the correct logger initialization using get_logger(__name__)

Problem
The logger was initialized twice:

  1. Line 23: logger = get_logger(__name__) (Correct - uses custom logger)
  2. Line 29: logger = logging.getLogger(__name__) (Duplicate - overwrites custom logger)

This caused:

  • Loss of custom logging configuration (color coding, component prefixes)
  • Inconsistent logging behavior
  • Unused import

Solution

  • Single logger initialization using the project's custom get_logger() function
  • Removed unused import
  • Ensures consistent logging with proper formatting

Testing

  • Verified logger works correctly with custom formatting
  • All linting checks passed (Ruff, Black)
  • Application tested: Add folder, enable AI tagging, face clusters all working
  • No breaking changes

Impact

  • Before: Custom logger was overwritten, losing formatting and configuration
  • After: Single, properly configured logger with consistent behavior

Closes #815 issue

Summary by CodeRabbit

  • Chores
    • Improved internal logging infrastructure for better maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

- Remove duplicate logger initialization on line 29
- Remove unused 'import logging' statement
- Keep only the correct logger initialization using get_logger()

Fixes: Duplicate logger initialization causing custom logger to be overwritten
Impact: Ensures consistent logging behavior with proper formatting and configuration
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

Walkthrough

A single file fix that removes duplicate logger initialization and an unused logging import from the images utility module, retaining only the project's custom logger implementation.

Changes

Cohort / File(s) Summary
Logger deduplication
backend/app/utils/images.py
Removed import logging statement and duplicate logger initialization using logging.getLogger(), keeping only the project's get_logger() implementation for consistent logging configuration

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Straightforward cleanup with no functional logic changes
  • Single file affected with simple removal operations
  • Fix directly addresses the reported duplicate initialization issue

Poem

🐰 Two loggers logging, oh what a sight,
One had to go—we picked what was right!
Now get_logger() stands alone, proud and true,
Custom formatting flows through and through! 📝✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing duplicate logger initialization in images.py, which is the core objective of the PR.
Linked Issues check ✅ Passed The PR successfully addresses all objectives from issue #815: removes duplicate logger initialization, eliminates unused logging import, and preserves the project's custom get_logger function.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #815; only the duplicate logger initialization and unused import were removed from images.py with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

BUG: Duplicate Logger Initialization in backend/app/utils/images.py

1 participant