mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-24 13:49:27 +00:00
Mostly just updating libraries, removing string encoding/decoding, fixing some edge cases. No new functionality was added in this commit.
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
import pprint
|
|
import sys
|
|
import threading
|
|
import traceback
|
|
|
|
from headphones import logger
|
|
|
|
|
|
def cry():
|
|
"""
|
|
Logs thread traces.
|
|
"""
|
|
tmap = {}
|
|
main_thread = None
|
|
# get a map of threads by their ID so we can print their names
|
|
# during the traceback dump
|
|
for t in threading.enumerate():
|
|
if t.ident:
|
|
tmap[t.ident] = t
|
|
else:
|
|
main_thread = t
|
|
|
|
# Loop over each thread's current frame, writing info about it
|
|
for tid, frame in sys._current_frames().items():
|
|
thread = tmap.get(tid, main_thread)
|
|
|
|
lines = []
|
|
lines.append('%s\n' % thread.getName())
|
|
lines.append('========================================\n')
|
|
lines += traceback.format_stack(frame)
|
|
lines.append('========================================\n')
|
|
lines.append('LOCAL VARIABLES:\n')
|
|
lines.append('========================================\n')
|
|
lines.append(pprint.pformat(frame.f_locals))
|
|
lines.append('\n\n')
|
|
logger.info("".join(lines))
|