refactor(logging): Add optional logging support throughout codebase
Add centralized logging utility and optional logger parameters to all core functions for better observability and debugging capabilities. New modules: - utils/logging.py: Centralized logger configuration with console and optional file handlers Enhanced features: - Added optional logger parameter to all extractor_core functions - Added logger support to extractor, excel_converter, and auth modules - Functions remain silent when logger=None (backward compatible) - Improved environment variable validation in test files Documentation: - Added discrete_material_plan_extractor_core.md with complete API reference and usage patterns Benefits: - Consistent logging format across all components - Optional debug output for troubleshooting - No breaking changes - fully backward compatible - Better error messages and validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,12 +86,20 @@ try:
|
||||
# Setup browser and extract data
|
||||
print("\n[3/6] Launching browser and logging in...")
|
||||
with sync_playwright() as playwright:
|
||||
# Get required environment variables (with validation)
|
||||
username = os.getenv("ERP_USERNAME")
|
||||
password = os.getenv("ERP_PASSWORD")
|
||||
base_url = os.getenv("ERP_URL")
|
||||
|
||||
if not username or not password or not base_url:
|
||||
raise ValueError("Missing required environment variables: ERP_USERNAME, ERP_PASSWORD, ERP_URL")
|
||||
|
||||
# Login
|
||||
browser, context, page, main_frame = login(
|
||||
playwright=playwright,
|
||||
username=os.getenv("ERP_USERNAME"),
|
||||
password=os.getenv("ERP_PASSWORD"),
|
||||
url=get_login_url(os.getenv("ERP_URL")),
|
||||
username=username,
|
||||
password=password,
|
||||
url=get_login_url(base_url),
|
||||
headless=os.getenv("ERP_HEADLESS", "true").lower() == "true",
|
||||
ignore_https_errors=os.getenv("ERP_IGNORE_HTTPS_ERRORS", "true").lower() == "true",
|
||||
verbose=True,
|
||||
|
||||
Reference in New Issue
Block a user