refactor(logging): migrate service classes to centralized get_logger()#22
Open
Kunal-Somani wants to merge 1 commit intoruxailab:mainfrom
Open
refactor(logging): migrate service classes to centralized get_logger()#22Kunal-Somani wants to merge 1 commit intoruxailab:mainfrom
Kunal-Somani wants to merge 1 commit intoruxailab:mainfrom
Conversation
- Remove coloredlogs.install() calls from EmotionsAnalysisImp.__init__() and FirebaseImp.__init__() — reinstalling the log handler on every object instantiation was causing duplicate log entries - Replace instance-level self.logger with module-level logger via get_logger(__name__) for consistency with utils/logger.py (PR ruxailab#21) - Switch all f-string log calls to % formatting (Python logging best practice — avoids string interpolation when log level is disabled) - Add debug log to FirebaseImp._initialize_app() for the already- initialized path - Add logger.info() to upload_to_firestore() on successful Firestore write - Remove unused logging and coloredlogs imports from both files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two service classes were directly calling
coloredlogs.install()inside their__init__methods:EmotionsAnalysisImp.__init__()FirebaseImp.__init__()This caused the log handler to be reinstalled on every object instantiation, producing duplicate log entries whenever a new service instance was created during a request cycle.
Changes
services/emotion_analysis/emotion_analysis_imp.pycoloredlogs.install()from__init__self.logger— replaced with module-levellogger = get_logger(__name__)consistent with PR feat(logging): add centralized logger factory and replace print statements #21loggingandcoloredlogsimportsservices/data/firebase_imp.pycoloredlogs.install()from__init__loggerclass attribute and instance reassignmentlogger.debug()to the already-initialized path in_initialize_app()for better traceabilitylogger.info()toupload_to_firestore()on successful writeloggingandcoloredlogsimportsRoot Cause
Neither service was using the centralized
get_logger()factory introduced in PR #21. This PR completes the migration so all modules share one consistent logging configuration controlled by theLOG_LEVELenv var.