encode to utf8 before writing log

This commit is contained in:
Damien Elmes 2013-10-18 15:21:54 +09:00
parent 313fc7c9ef
commit 0ac8789ad5

View file

@ -867,10 +867,10 @@ the problem and restart Anki.""")
return pprint.pformat(x)
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,
buf = u"[%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())
open(lpath, "ab").write(buf + "\n")
open(lpath, "ab").write(buf.encode("utf8") + "\n")
if os.environ.get("LOG"):
print buf