fix: Initialize logger before use in github_scraper.py
Fixes Issue #190 - "name 'logger' is not defined" error **Problem:** - Logger was used at line 40 (in code_analyzer import exception) - Logger was defined at line 47 - Caused runtime error when code_analyzer import failed **Solution:** - Moved logging.basicConfig() and logger initialization to lines 34-39 - Now logger is defined BEFORE the code_analyzer import block - Warning message now works correctly when code_analyzer is missing **Testing:** - ✅ All 22 GitHub scraper tests pass - ✅ Logger warning appears correctly when code_analyzer missing - ✅ No similar issues found in other CLI files Closes #190
This commit is contained in:
@@ -31,6 +31,13 @@ except ImportError:
|
||||
print("Error: PyGithub not installed. Run: pip install PyGithub")
|
||||
sys.exit(1)
|
||||
|
||||
# Configure logging FIRST (before using logger)
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Import code analyzer for deep code analysis
|
||||
try:
|
||||
from .code_analyzer import CodeAnalyzer
|
||||
@@ -39,13 +46,6 @@ except ImportError:
|
||||
CODE_ANALYZER_AVAILABLE = False
|
||||
logger.warning("Code analyzer not available - deep analysis disabled")
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GitHubScraper:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user