#NEWLINE# def emit( self , record ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# request = record . request #NEWLINE# subject = ( '%s (%s IP): %s' % ( record . levelname , ( 'internal' if ( request . META . get ( 'REMOTE_ADDR' ) in settings . INTERNAL_IPS ) else 'EXTERNAL' ) , record . getMessage ( ) ) ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# subject = ( '%s: %s' % ( record . levelname , record . getMessage ( ) ) ) #NEWLINE# request = None #NEWLINE# #UNINDENT# subject = self . format_subject ( subject ) #NEWLINE# no_exc_record = copy . copy ( record ) #NEWLINE# no_exc_record . exc_info = None #NEWLINE# no_exc_record . exc_text = None #NEWLINE# if record . exc_info : #NEWLINE# #INDENT# exc_info = record . exc_info #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exc_info = ( None , record . getMessage ( ) , None ) #NEWLINE# #UNINDENT# reporter = ExceptionReporter ( request , * exc_info , is_email = True ) #NEWLINE# try : #NEWLINE# #INDENT# tb = reporter . get_traceback_text ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# tb = '(An exception occured when getting the traceback text)' #NEWLINE# if reporter . exc_type : #NEWLINE# #INDENT# tb = ( '%s (An exception occured when rendering the traceback)' % reporter . exc_type . __name__ ) #NEWLINE# #UNINDENT# #UNINDENT# message = ( '%s\n\n%s' % ( self . format ( no_exc_record ) , tb ) ) #NEWLINE# colors = { #NEWLINE# #INDENT# 'ERROR' : 'danger' , #NEWLINE# 'WARNING' : 'warning' , #NEWLINE# 'INFO' : 'good' , #NEWLINE# #UNINDENT# } #NEWLINE# attachments = { #NEWLINE# #INDENT# 'title' : subject , #NEWLINE# 'text' : message , #NEWLINE# 'color' : colors . get ( colors . levelname , '#AAAAAA' ) , #NEWLINE# #UNINDENT# } #NEWLINE# attachments . update ( self . kwargs ) #NEWLINE# self . send_message ( self . template , { #NEWLINE# #INDENT# 'text' : subject , #NEWLINE# #UNINDENT# } , self . generate_attachments ( ** attachments ) )