3
g                 @   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                sT   yt  j|| W n< tk
rN } z tj|tj ddid  W Y d d }~X nX d S )Nstatus_codei  )exc_infoextra)superexecute	Exceptionloggererrorsysr   )selfargsoptionse)	__class__ _/var/www/tester-filtro-web/env/lib/python3.6/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   