# -*- coding: utf-8 -*-
"""
Core app configuration.

This module defines the Django app configuration for the core app,
which provides shared functionality across all other apps.
It defines the app's metadata and any initialization logic.

"""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class CoreConfig(AppConfig):
    """
    Configuration class for the common app.
    
    This app provides shared models, utilities, and functionality
    that can be used across all other applications in the project.
    """
    
    # 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.core"
    # Human-readable name for the app
    verbose_name = _("Core")
    
    def ready(self):
        """
        Perform initialization when the app is ready.
        
        This method is called when Django starts up and the app
        registry is fully populated.
        
        This method is called when the app is ready and can be used to:
        - Import signal handlers
        - Register custom checks 
        - Perform other initialization tasks
        - Set up user-related logging
        """
        # Import signals to ensure they are registered
        try:
            # Import signal handlers
            from . import signals  # noqa
        except ImportError:
            pass
        
        # Import any other initialization code
        try:
            # Import and register custom checks
            from . import checks  # noqa
        except ImportError:
            pass

        # Import any other initialization code
        try:
            # Import and set up user-related logging
            from . import logging  # noqa
            # Initialize logging configuration
            self._setup_logging()
        except ImportError:
            pass

    def _setup_logging(self):
        """Setup application-specific logging configuration.
        
        This method can be used to set up custom logging configuration for the
        core app. It's especially useful when customizing log levels,
        handlers, or formats.
        """
        import logging
        
        logger = logging.getLogger('adtlas.core')
        logger.info('core app initialized successfully')    