mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
more logging tweaks
- disable in browser, note.cards() - in getCard() we want the calling frame, not us - log current day - show card/note id in card info stat
This commit is contained in:
parent
9b2109b85a
commit
0fbc94c186
6 changed files with 18 additions and 9 deletions
|
@ -205,9 +205,10 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
|||
# Object creation helpers
|
||||
##########################################################################
|
||||
|
||||
def getCard(self, id):
|
||||
def getCard(self, id, log=True):
|
||||
c = anki.cards.Card(self, id)
|
||||
self.log(c)
|
||||
if log:
|
||||
self.log(c, stack=1)
|
||||
return c
|
||||
|
||||
def getNote(self, id):
|
||||
|
@ -774,5 +775,5 @@ and queue = 0""", intTime(), self.usn())
|
|||
# Logging
|
||||
##########################################################################
|
||||
|
||||
def log(self, *args):
|
||||
runHook("log", args)
|
||||
def log(self, *args, **kwargs):
|
||||
runHook("log", args, kwargs)
|
||||
|
|
|
@ -69,7 +69,7 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""",
|
|||
return joinFields(self.fields)
|
||||
|
||||
def cards(self):
|
||||
return [self.col.getCard(id) for id in self.col.db.list(
|
||||
return [self.col.getCard(id, log=False) for id in self.col.db.list(
|
||||
"select id from cards where nid = ? order by ord", self.id)]
|
||||
|
||||
def model(self):
|
||||
|
|
|
@ -1123,6 +1123,7 @@ did = ?, queue = %s, due = ?, mod = ?, usn = ? where id = ?""" % queue, data)
|
|||
self.today = int((time.time() - self.col.crt) // 86400)
|
||||
# end of day cutoff
|
||||
self.dayCutoff = self.col.crt + (self.today+1)*86400
|
||||
self.col.log(self.today, self.dayCutoff)
|
||||
# update all daily counts, but don't save decks to prevent needless
|
||||
# conflicts. we'll save on card answer instead
|
||||
def update(g):
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from __future__ import division
|
||||
import time, datetime, json
|
||||
import time
|
||||
import datetime
|
||||
import json
|
||||
|
||||
import anki.js
|
||||
from anki.utils import fmtTimeSpan, ids2str
|
||||
from anki.lang import _, ngettext
|
||||
|
||||
|
||||
# Card stats
|
||||
##########################################################################
|
||||
|
||||
|
@ -56,6 +60,8 @@ class CardStats(object):
|
|||
self.addLine(_("Card Type"), c.template()['name'])
|
||||
self.addLine(_("Note Type"), c.model()['name'])
|
||||
self.addLine(_("Deck"), self.col.decks.name(c.did))
|
||||
self.addLine(_("Note ID"), c.nid)
|
||||
self.addLine(_("Card ID"), c.id)
|
||||
self.txt += "</table>"
|
||||
return self.txt
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class DataModel(QAbstractTableModel):
|
|||
def getCard(self, index):
|
||||
id = self.cards[index.row()]
|
||||
if not id in self.cardObjs:
|
||||
self.cardObjs[id] = self.col.getCard(id)
|
||||
self.cardObjs[id] = self.col.getCard(id, log=False)
|
||||
return self.cardObjs[id]
|
||||
|
||||
def refreshNote(self, note):
|
||||
|
|
|
@ -860,12 +860,13 @@ the problem and restart Anki.""")
|
|||
# Debug logging
|
||||
##########################################################################
|
||||
|
||||
def onLog(self, args):
|
||||
def onLog(self, args, kwargs):
|
||||
def customRepr(x):
|
||||
if isinstance(x, basestring):
|
||||
return x
|
||||
return pprint.pformat(x)
|
||||
path, num, fn, y = traceback.extract_stack(limit=4)[0]
|
||||
path, num, fn, y = traceback.extract_stack(
|
||||
limit=4+kwargs.get("stack", 0))[0]
|
||||
buf = "[%s] %s:%s(): %s" % (intTime(), os.path.basename(path), fn,
|
||||
", ".join([customRepr(x) for x in args]))
|
||||
lpath = re.sub("\.anki2$", ".log", self.pm.collectionPath())
|
||||
|
|
Loading…
Reference in a new issue