mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
add TimedLog for debugging
This commit is contained in:
parent
e5ed110d65
commit
85488afb8f
1 changed files with 13 additions and 0 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue