import os
def print_config(settings_obj):
"""
Prints the application's configuration to the console, masking sensitive values.
"""
print("--- ⚙️ Application Configuration ---")
sensitive_keywords = ["KEY", "TOKEN", "SECRET", "PASSWORD"]
# Use sorted(dir(...)) to ensure a consistent output order for tests
for key in sorted(dir(settings_obj)):
# Skip private/dunder methods
if key.startswith('_'):
continue
value = getattr(settings_obj, key)
# **CRITICAL FIX**: Skip attributes that are methods/functions
if callable(value):
continue
if any(k in key for k in sensitive_keywords):
if isinstance(value, str) and len(value) > 8:
masked_value = f"{value[:4]}...{value[-4:]}"
else:
masked_value = "***"
print(f" - {key}: {masked_value}")
else:
print(f" - {key}: {value}")
print("------------------------------------")