Commit 87001ce3 authored by Jérome Perrin's avatar Jérome Perrin

wsgixmlrpcapplication,manager: log errors

Log tracebacks on error
parent ebeac211
...@@ -275,8 +275,7 @@ class Manager(object): ...@@ -275,8 +275,7 @@ class Manager(object):
del response_dict['meta']['Data'] del response_dict['meta']['Data']
return (200, response_dict, "") return (200, response_dict, "")
except Exception as e: except Exception as e:
import traceback; logger.error('Error converting to %s', extension, exc_info=True)
logger.error(traceback.format_exc())
return (402, {}, e.args[0]) return (402, {}, e.args[0])
def run_setmetadata(self, filename='', data=None, meta=None, def run_setmetadata(self, filename='', data=None, meta=None,
...@@ -292,8 +291,7 @@ class Manager(object): ...@@ -292,8 +291,7 @@ class Manager(object):
response_dict['data'] = self.updateFileMetadata(data, extension, meta) response_dict['data'] = self.updateFileMetadata(data, extension, meta)
return (200, response_dict, '') return (200, response_dict, '')
except Exception as e: except Exception as e:
import traceback; logger.error('Error setting metadata', exc_info=True)
logger.error(traceback.format_exc())
return (402, {}, e.args[0]) return (402, {}, e.args[0])
def run_getmetadata(self, filename='', data=None, meta=None, def run_getmetadata(self, filename='', data=None, meta=None,
...@@ -312,8 +310,7 @@ class Manager(object): ...@@ -312,8 +310,7 @@ class Manager(object):
response_dict['meta']['title'] = response_dict['meta']['Title'] response_dict['meta']['title'] = response_dict['meta']['Title']
return (200, response_dict, '') return (200, response_dict, '')
except Exception as e: except Exception as e:
import traceback; logger.error('Error getting metadata', exc_info=True)
logger.error('run_getmetadata: ' + traceback.format_exc())
return (402, {}, e.args[0]) return (402, {}, e.args[0])
def run_generate(self, filename='', data=None, meta=None, extension=None, def run_generate(self, filename='', data=None, meta=None, extension=None,
...@@ -354,8 +351,7 @@ class Manager(object): ...@@ -354,8 +351,7 @@ class Manager(object):
mimetypes.types_map.get('.%s' % extension.split('.')[-1])) mimetypes.types_map.get('.%s' % extension.split('.')[-1]))
return (200, response_dict, "") return (200, response_dict, "")
except Exception as e: except Exception as e:
import traceback; logger.error('Error in generate from %s to %s', orig_format, extension, exc_info=True)
logger.error(traceback.format_exc())
return (402, response_dict, str(e)) return (402, response_dict, str(e))
def getAllowedTargetItemList(self, content_type): def getAllowedTargetItemList(self, content_type):
...@@ -374,7 +370,7 @@ class Manager(object): ...@@ -374,7 +370,7 @@ class Manager(object):
response_dict['response_data'] = extension_list response_dict['response_data'] = extension_list
return (200, response_dict, '') return (200, response_dict, '')
except Exception as e: except Exception as e:
logger.error(e) logger.error('Error in getting target item list from %s', content_type, exc_info=True)
return (402, {}, e.args[0]) return (402, {}, e.args[0])
def _getOOGranulator(self, data, source_format="odt"): def _getOOGranulator(self, data, source_format="odt"):
......
...@@ -12,16 +12,30 @@ ...@@ -12,16 +12,30 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
logger = logging.getLogger(__name__)
class WSGIXMLRPCApplication(object): class ErrorLoggingXMLRPCDispatcher(SimpleXMLRPCDispatcher):
"""A XMLRPC Dispatcher which logs errors
"""
def _dispatch(self, method, params):
try:
return SimpleXMLRPCDispatcher._dispatch(self, method, params)
except:
logger.exception("Error calling %s", method)
raise
class WSGIXMLRPCApplication:
"""Application to handle requests to the XMLRPC service""" """Application to handle requests to the XMLRPC service"""
def __init__(self, instance=None, methods=[]): def __init__(self, instance=None, methods=[]):
"""Create windmill xmlrpc dispatcher""" """Create windmill xmlrpc dispatcher"""
self.dispatcher = SimpleXMLRPCDispatcher(allow_none=True, self.dispatcher = ErrorLoggingXMLRPCDispatcher(
encoding=None) allow_none=True,
encoding=None)
if instance is not None: if instance is not None:
self.dispatcher.register_instance(instance) self.dispatcher.register_instance(instance)
for method in methods: for method in methods:
...@@ -63,6 +77,7 @@ class WSGIXMLRPCApplication(object): ...@@ -63,6 +77,7 @@ class WSGIXMLRPCApplication(object):
response += '\n' response += '\n'
except: # This should only happen if the module is buggy except: # This should only happen if the module is buggy
# internal error, report as HTTP server error # internal error, report as HTTP server error
logger.exception("Error serving request")
start_response("500 Server error", [('Content-Type', start_response("500 Server error", [('Content-Type',
'text/plain')]) 'text/plain')])
return [] return []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment