o
    uvXj¯  ã                   @   s<   d dl Z d dlmZ d dlmZ edƒZG dd„ deƒZdS )é    N)ÚBaseCommand)Ú	getLoggerzdjango.commandsc                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚLoggingBaseCommandaß  
    A subclass of BaseCommand that logs run time errors to `django.commands`.
    To use this, create a management command subclassing LoggingBaseCommand:

        from django_extensions.management.base import LoggingBaseCommand

        class Command(LoggingBaseCommand):
            help = 'Test error'

            def handle(self, *args, **options):
                raise Exception


    And then define a logging handler in settings.py:

        LOGGING = {
            ... # Other stuff here

            'handlers': {
                'mail_admins': {
                    'level': 'ERROR',
                    'filters': ['require_debug_false'],
                    'class': 'django.utils.log.AdminEmailHandler'
                },
            },
            'loggers': {
                'django.commands': {
                    'handlers': ['mail_admins'],
                    'level': 'ERROR',
                    'propagate': False,
                },
            }

        }

    c              
      sP   zt t| ƒj|i |¤Ž W d S  ty' } ztj|t ¡ ddid� ‚ d }~ww )NÚstatus_codeiô  )Úexc_infoÚextra)Úsuperr   ÚexecuteÚ	ExceptionÚloggerÚerrorÚsysr   )ÚselfÚargsÚoptionsÚe©Ú	__class__© ú^/var/www/html/myproject/venv/lib/python3.10/site-packages/django_extensions/management/base.pyr	   0   s   €þzLoggingBaseCommand.execute)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Ú__classcell__r   r   r   r   r   
   s    %r   )r   Údjango.core.management.baser   Úloggingr   r   r   r   r   r   r   Ú<module>   s
   