def format_html(fp, exclude=()):
frames = stackframes()
fp.write('<!DOCTYPE html>\n')
fp.write('<html><head><title>{} Traces</title></head><body>\n'.format(len(frames)))
for thread_id, stack in sorted(frames.items(), key=lambda x: x[0]):
name = 'Thread {}'.format(thread_id)
if thread_id == threading.get_ident():
name += ' (tracing thread)'
elif thread_id == main_thread.ident:
name += ' (main)'
fp.write('<h3>{}</h3>\n'.format(name))
tbstr = format_stack(stack)
if pygments:
formatter = pygments.formatters.HtmlFormatter(full=False, noclasses=True)
lexer = pygments.lexers.PythonLexer()
tbstr = pygments.highlight(tbstr, lexer, formatter)
fp.write(tbstr)
fp.write('\n')
fp.write('</body>\n')
评论列表
文章目录