AOSSIE-Org / AOSSIE-Org/PictoPy

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

Abierto
#815 10 comentarios 1 reacción 1 asignado Reclamado por @Sanskriti0805 Ver en GitHub
backend bug
Lenguaje dominante
Python
Estrellas
283
Forks
679
Merge medio
7 d 2 h
PR fusionados (30 d)
3

Descripción

### Is there an existing issue for this?

- [x] I have searched the existing issues

### What happened?

Description
The `backend/app/utils/images.py` file contains duplicate logger initialization, causing the custom configured logger to be overwritten by a standard Python logger. This results in inconsistent logging behavior and loss of the project's custom logging configuration (color formatting, component prefixes, etc.).

Location
**File:** `backend/app/utils/images.py`
**Lines:** 23 and 29

Problem
1. Duplicate Initialization: The logger is initialized twice on lines 23 and 29
2. Overwrites Custom Logger: The second initialization uses `logging.getLogger()` instead of the project's `get_logger()`, which overwrites the properly configured logger
3. Unused Import: The `logging` module is imported but only used for the duplicate initialization
4. Loss of Configuration: The custom logger from `get_logger()` includes:
- Color-coded log messages
- Component-specific prefixes
- Consistent formatting across the project
- Environment-based configuration

Impact
- Inconsistent Logging: Logs from this module may not follow the project's logging standards
- Lost Formatting: Missing color coding and component prefixes in log output
- Code Quality: Unused import and redundant code
- Maintenance: Confusing for developers who expect consistent logging behavior

Expected Behavior
The module should use a single logger instance initialized with the project's custom `get_logger()` function, ensuring consistent logging behavior with proper formatting and configuration.

Solution
1. Remove the duplicate logger initialization on line 29
2. Remove the unused `import logging` statement
3. Keep only the correct initialization: `logger = get_logger(__name__)`

Steps to Reproduce
1. Check the log output from image processing operations
2. Observe that logs may not have the expected formatting/colors
3. Review the code to see duplicate logger initialization

Additional Context
- The project uses a centralized logging system via `app.logging.setup_logging.get_logger()`
- This function returns a properly configured logger with custom formatting
- All modules should use `get_logger(__name__)` instead of `logging.getLogger(__name__)`

Labels
- `bug`
- `backend`
- `logging`
- `code-quality`
- `good-first-issue` (simple fix, good for new contributors)

Priority
**Low-Medium** - Doesn't break functionality but affects code quality and logging consistency

### Record

- [x] I agree to follow this project's Code of Conduct

### Checklist before Submitting

- [ ] Have you updated docs for it?
- [ ] Have you added unit tests?
- [ ] Have you made sure unit tests pass?
- [x] Have you made sure code formatting is correct?
- [ ] Do Your changes passes all tests?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.