# -*- coding: utf-8 -*- 
"""Auth App Configuration

This module contains the Django app configuration for the auth application.
The auth app handles user authentication, authorization.
It defines the app's metadata and any initialization logic.
"""

from django.apps import AppConfig


class AuthenticationConfig(AppConfig):
    """Configuration for the Auth application.
    
    This app handles user authentication, authorization.
    """
    
    # Use BigAutoField as the default primary key field type
    default_auto_field = 'django.db.models.BigAutoField'
    
    # App name as it appears in INSTALLED_APPS
    name = 'apps.authentication'
    
    # Human-readable name for the app
    verbose_name = 'authentication' 
    
    def ready(self): 
        """Initialize the app when Django starts.
        
        This method is called when the app is ready and can be used to:
        - Import signal handlers
        - Register custom checks
        - Initialize authentication configurations
        - Perform other initialization tasks
        - Set up user-related logging
        """
        try:
            # Import signal handlers
            from . import signals  # noqa: F401
            
            # Import and register custom checks
            from . import checks  # noqa: F401
            
            # Initialize logging configuration
            self._setup_logging()
            
            # Setup authentication backends
            self._setup_authentication()
            
        except ImportError:
            # Handle cases where signal modules don't exist yet
            pass
    
    def _setup_logging(self):
        """Setup application-specific logging configuration.
        
        This method can be used to set up custom logging configuration for the
        auth app. It's especially useful when customizing log levels,
        handlers, or formats.
        """
        import logging
        
        logger = logging.getLogger('adtlas.auth')
        logger.info('Auth app initialized successfully')    
    
    def _setup_authentication(self):
        """Setup authentication-specific configurations.
        
        This method can be used to set up custom authentication backends,
        custom user models, or any other authentication-related configurations.
        """
        # Any authentication setup can be done here
        pass