mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add list of extensions to the traceback log file on unhandled exceptions.
This commit is contained in:
parent
e56b38f528
commit
df955e6340
@ -238,6 +238,7 @@ def main(argv):
|
||||
print >>status, 'Making output directory...'
|
||||
os.makedirs(outdir)
|
||||
|
||||
app = None
|
||||
try:
|
||||
app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
|
||||
confoverrides, status, warning, freshenv,
|
||||
@ -267,7 +268,7 @@ def main(argv):
|
||||
else:
|
||||
print >>error, red('Exception occurred:')
|
||||
print >>error, format_exception_cut_frames().rstrip()
|
||||
tbpath = save_traceback()
|
||||
tbpath = save_traceback(app)
|
||||
print >>error, red('The full traceback has been saved '
|
||||
'in %s, if you want to report the '
|
||||
'issue to the developers.' % tbpath)
|
||||
|
@ -177,18 +177,24 @@ _DEBUG_HEADER = '''\
|
||||
# Python version: %s
|
||||
# Docutils version: %s %s
|
||||
# Jinja2 version: %s
|
||||
# Loaded extensions: %s
|
||||
'''
|
||||
|
||||
def save_traceback():
|
||||
def save_traceback(app):
|
||||
"""Save the current exception's traceback in a temporary file."""
|
||||
import platform
|
||||
exc = traceback.format_exc()
|
||||
fd, path = tempfile.mkstemp('.log', 'sphinx-err-')
|
||||
if app is not None:
|
||||
extension_list = ', '.join(app._extensions)
|
||||
else:
|
||||
extension_list = '(app not created)'
|
||||
os.write(fd, (_DEBUG_HEADER %
|
||||
(sphinx.__version__,
|
||||
platform.python_version(),
|
||||
docutils.__version__, docutils.__version_details__,
|
||||
jinja2.__version__)).encode('utf-8'))
|
||||
jinja2.__version__,
|
||||
extension_list)).encode('utf-8'))
|
||||
os.write(fd, exc.encode('utf-8'))
|
||||
os.close(fd)
|
||||
return path
|
||||
|
Loading…
Reference in New Issue
Block a user