a
    ÆZEg—  ã                   @   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              
      sZ   zt ƒ j|i |¤Ž W n> tyT } z&tj|t ¡ ddid� ‚ W Y d }~n
d }~0 0 d S )NÚstatus_codeiô  )Úexc_infoÚextra)ÚsuperÚexecuteÚ	ExceptionÚloggerÚerrorÚsysr   )ÚselfÚargsÚoptionsÚe©Ú	__class__© úZ/var/www/sistema_ama/venv/lib/python3.9/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   Zdjango.core.management.baser   Úloggingr   r   r   r   r   r   r   Ú<module>   s   