##// END OF EJS Templates
vcsserver: log exceptions into the logs
milka -
r939:b166ecdf stable
parent child
Show More
@@ -433,7 +433,7 class HTTPApplication(object):
433 should_store_exc = False
433 should_store_exc = False
434
434
435 if should_store_exc:
435 if should_store_exc:
436 store_exception(id(exc_info), exc_info)
436 store_exception(id(exc_info), exc_info, request_path=request.path)
437
437
438 tb_info = ''.join(
438 tb_info = ''.join(
439 traceback.format_exception(exc_type, exc_value, exc_traceback))
439 traceback.format_exception(exc_type, exc_value, exc_traceback))
@@ -452,6 +452,7 class HTTPApplication(object):
452 'type': type_
452 'type': type_
453 }
453 }
454 }
454 }
455
455 try:
456 try:
456 resp['error']['_vcs_kind'] = getattr(e, '_vcs_kind', None)
457 resp['error']['_vcs_kind'] = getattr(e, '_vcs_kind', None)
457 except AttributeError:
458 except AttributeError:
@@ -68,7 +68,7 def get_exc_store():
68 return _exc_store_path
68 return _exc_store_path
69
69
70
70
71 def _store_exception(exc_id, exc_info, prefix):
71 def _store_exception(exc_id, exc_info, prefix, request_path=''):
72 exc_type, exc_value, exc_traceback = exc_info
72 exc_type, exc_value, exc_traceback = exc_info
73
73
74 tb = ''.join(traceback.format_exception(
74 tb = ''.join(traceback.format_exception(
@@ -101,8 +101,13 def _store_exception(exc_id, exc_info, p
101 f.write(exc_data)
101 f.write(exc_data)
102 log.debug('Stored generated exception %s as: %s', exc_id, stored_exc_path)
102 log.debug('Stored generated exception %s as: %s', exc_id, stored_exc_path)
103
103
104 log.error(
105 'error occurred handling this request.\n'
106 'Path: `%s`, tb: %s',
107 request_path, tb)
104
108
105 def store_exception(exc_id, exc_info, prefix=global_prefix):
109
110 def store_exception(exc_id, exc_info, prefix=global_prefix, request_path=''):
106 """
111 """
107 Example usage::
112 Example usage::
108
113
@@ -111,7 +116,8 def store_exception(exc_id, exc_info, pr
111 """
116 """
112
117
113 try:
118 try:
114 _store_exception(exc_id=exc_id, exc_info=exc_info, prefix=prefix)
119 _store_exception(exc_id=exc_id, exc_info=exc_info, prefix=prefix,
120 request_path=request_path)
115 except Exception:
121 except Exception:
116 log.exception('Failed to store exception `%s` information', exc_id)
122 log.exception('Failed to store exception `%s` information', exc_id)
117 # there's no way this can fail, it will crash server badly if it does.
123 # there's no way this can fail, it will crash server badly if it does.
General Comments 0
You need to be logged in to leave comments. Login now