X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/84b7c247d55c191d6ab898e812a578d304db7989..179c06a914a8364b4bc571a0da3bed467b4d7f76:/erebus.py diff --git a/erebus.py b/erebus.py index 7588838..713c384 100644 --- a/erebus.py +++ b/erebus.py @@ -6,8 +6,8 @@ import os, sys, select, MySQLdb, MySQLdb.cursors, time, random import bot, config, ctlmod -class Erebus(object): - APIVERSION = 1 +class Erebus(object): #singleton to pass around + APIVERSION = 2 RELEASE = 0 bots = {} @@ -204,6 +204,9 @@ class Erebus(object): def module(self, name): return ctlmod.modules[name] + def log(self, source, level, message): + print "%09.3f %s [%s] %s" % (time.time() % 100000, source, level, message) + #bind functions def hook(self, word, handler): try: @@ -247,11 +250,13 @@ class Erebus(object): class MyCursor(MySQLdb.cursors.DictCursor): def execute(self, *args, **kwargs): - print "%09.3f [SQL] [#] MyCursor.execute(self, %s, %s)" % (time.time() % 100000, ', '.join([repr(i) for i in args]), ', '.join([str(key)+"="+repr(kwargs[key]) for key in kwargs])) + main.log("[SQL]", "?", "MyCursor.execute(self, %s, %s)" % (', '.join([repr(i) for i in args]), ', '.join([str(key)+"="+repr(kwargs[key]) for key in kwargs]))) +# print "%09.3f [SQL] [#] MyCursor.execute(self, %s, %s)" % (time.time() % 100000, ', '.join([repr(i) for i in args]), ', '.join([str(key)+"="+repr(kwargs[key]) for key in kwargs])) try: - super(self.__class__, self).execute(*args, **kwargs) + return super(self.__class__, self).execute(*args, **kwargs) except MySQLdb.MySQLError as e: - print "%09.3f [SQL] [!] MySQL error! %r" % (time.time() % 100000, e) + main.log("[SQL]", "!", "MySQL error! %r" % (e)) +# print "%09.3f [SQL] [!] MySQL error! %r" % (time.time() % 100000, e) dbsetup() return False return True