add TimedLog for debugging

This commit is contained in:
dae 2014-06-03 17:26:06 +09:00
parent e5ed110d65
commit 85488afb8f

View file

@ -17,6 +17,7 @@ import sys
import locale
from hashlib import sha1
import platform
import traceback
from anki.lang import _, ngettext
@ -384,3 +385,15 @@ def platDesc():
except:
continue
return theos
# Debugging
##############################################################################
class TimedLog(object):
def __init__(self):
self._last = time.time()
def log(self, s):
path, num, fn, y = traceback.extract_stack(limit=2)[0]
sys.stderr.write("%5dms: %s(): %s\n" % ((time.time() - self._last)*1000, fn, s))
self._last = time.time()