#NEWLINE# def log_error( request , view , action , errors , exc_info = None ) : #NEWLINE# #INDENT# error_msg = ( 'Error %s: %s' % ( action , format_error ( errors [ 0 ] ) ) ) #NEWLINE# log_kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( not exc_info ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# exc_info = full_exc_info ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# exc_info = None #NEWLINE# #UNINDENT# #UNINDENT# if ( ( exc_info and ( not isinstance ( exc_info , tuple ) ) ) or ( not len ( exc_info ) ) or ( not exc_info [ 0 ] ) ) : #NEWLINE# #INDENT# exc_info = None #NEWLINE# #UNINDENT# if proc_timestamp : #NEWLINE# #INDENT# log_kwargs [ 'exc_info' ] = exc_info #NEWLINE# #UNINDENT# extra_data = { #NEWLINE# #INDENT# 'errors' : errors , #NEWLINE# 'process_id' : os . getpid ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# import psutil , math , time , thread #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = psutil . Process ( os . getpid ( ) ) #NEWLINE# proc_timestamp = time . strftime ( '%Y-%m-%d %H:%M:%S' , time . localtime ( p . create_time ) ) #NEWLINE# try : #NEWLINE# #INDENT# create_usec = six . text_type ( ( p . create_time - math . floor ( p . create_time ) ) ) [ 1 : 5 ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# create_usec = '' #NEWLINE# #UNINDENT# proc_timestamp += create_usec #NEWLINE# extra_data [ 'process_create_date' ] = proc_timestamp #NEWLINE# extra_data [ 'thread_id' ] = thread . get_ident ( ) #NEWLINE# #UNINDENT# if isinstance ( errors [ 0 ] , CropDusterUrlException ) : #NEWLINE# #INDENT# urlconf = get_urlconf ( ) #NEWLINE# resolver = get_resolver ( urlconf ) #NEWLINE# extra_data [ 'resolver_data' ] = { #NEWLINE# #INDENT# 'regex' : resolver . regex , #NEWLINE# 'urlconf_name' : resolver . urlconf_name , #NEWLINE# 'default_kwargs' : resolver . default_kwargs , #NEWLINE# 'namespace' : resolver . namespace , #NEWLINE# 'urlconf_module' : resolver . urlconf_module , #NEWLINE# #UNINDENT# } #NEWLINE# resolver_reverse_dict = dict ( [ ( force_unicode ( k ) , resolver . reverse_dict [ k ] ) for k in resolver . reverse_dict ] ) #NEWLINE# resolver_namespace_dict = dict ( [ ( force_unicode ( k ) , resolver . namespace_dict [ k ] ) for k in resolver . namespace_dict ] ) #NEWLINE# extra_data . update ( { #NEWLINE# #INDENT# 'resolver_data' : { #NEWLINE# #INDENT# 'regex' : resolver . regex , #NEWLINE# 'urlconf_name' : resolver . urlconf_name , #NEWLINE# 'default_kwargs' : resolver . default_kwargs , #NEWLINE# 'namespace' : resolver . namespace , #NEWLINE# 'urlconf_module' : resolver . urlconf_module , #NEWLINE# #UNINDENT# } , #NEWLINE# 'resolver_reverse_dict' : resolver_reverse_dict , #NEWLINE# 'resolver_namespace_dict' : resolver_namespace_dict , #NEWLINE# 'resolver_app_dict' : resolver . app_dict , #NEWLINE# 'resolver_url_patterns' : resolver . url_patterns , #NEWLINE# 'urlconf' : urlconf , #NEWLINE# 'view' : ( 'cropduster.views.%s' % view ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# raven_kwargs = { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# 'extra' : extra_data , #NEWLINE# 'data' : { #NEWLINE# #INDENT# 'message' : error_msg , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if raven_client : #NEWLINE# #INDENT# if exc_info : #NEWLINE# #INDENT# return raven_client . get_ident ( raven_client . captureException ( exc_info = exc_info , ** raven_kwargs ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return raven_client . get_ident ( raven_client . captureMessage ( error_msg , ** raven_kwargs ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# extra_data . update ( { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# 'url' : request . path_info , #NEWLINE# #UNINDENT# } ) #NEWLINE# logger . error ( error_msg , extra = extra_data , ** log_kwargs ) #NEWLINE# return None