Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created May 20, 2011 08:17
Show Gist options
  • Save lxneng/982546 to your computer and use it in GitHub Desktop.
Save lxneng/982546 to your computer and use it in GitHub Desktop.
from xmlbuilder import XMLBuilder
def _generate_xml(self, exception):
_,_,trace = sys.exc_info()
xml = XMLBuilder()
with xml.notice(version = 2.0):
xml << ('api-key', self.environment.api_key)
with xml.notifier:
xml << ('name', self.environment.name)
xml << ('version', self.environment.version)
xml << ('url', self.environment.url)
with xml('server-environment'):
xml << ('environment-name', self.environment.environment_name)
with xml.error:
xml << ('class', exception.__class__.__name__)
xml << ('message', str(exception))
with xml.backtrace:
[xml << ('line', {'file':filename, 'number':line_number, 'method':function_name}) \
for filename, line_number, function_name, _ in traceback.extract_tb(trace)]
return str(xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment