diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-08-04 15:26:49 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-08-04 15:26:49 -0300 |
commit | 27c66ba593683aa167d364964b5385b9a0d0bdd8 (patch) | |
tree | 3afec735589c26272e28acef0e79f8370fa5b392 /sql.py | |
parent | 00b6b129f1848613404ead84ef2754fd1f614b8a (diff) | |
download | server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.gz server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.bz2 server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.xz server-27c66ba593683aa167d364964b5385b9a0d0bdd8.zip |
Add another verbosity level, otherwise debug.txt will be a monster
Diffstat (limited to 'sql.py')
-rw-r--r-- | sql.py | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -71,11 +71,12 @@ def save_player(token, mask=SQL_NONE): Player[token]["aptime"], Player[token]["userid"]) - stdout(sqlx) + stdout(sqlx, 2) try: w.execute(sqlx) except: - stdout("SQL.ERR: Error happened (save.player), commiting anyway due MyISAM...") + stdout("SQL.ERR: Error happened (save.player), commiting anyway due MyISAM...", 0) + stdout("Faulty: %s" % sqlx, 0) #w.execute("INSERT INTO ....") # <- Not in save_player #w.execute("REPLACE DELAYED....") # <- Not where you can't delete, but for inv @@ -128,7 +129,7 @@ def save_inv(token, mask=SQL_NONE, force=False): w.execute("""DELETE FROM `inventory` WHERE `userid` = %d AND `index` = %d""" % (uid, i)) - stdout("SQL.INV: Delete where uid %d and index %d" % (uid, i)) + stdout("SQL.INV: Delete where uid %d and index %d" % (uid, i), 2) i+=1 continue @@ -140,7 +141,7 @@ def save_inv(token, mask=SQL_NONE, force=False): % (m, uid, i, it["unit_id"], it["level"], it["exp"])) except: # Something went wrong! - print("ERROR Saving item index %d for player %d: %s\n%s" % (i, uid, str(it), fatalmsg)) + stdout("ERROR Saving item index %d for player %d: %s\n%s" % (i, uid, str(it), fatalmsg), 0) if not force: revert=True finally: @@ -149,14 +150,14 @@ def save_inv(token, mask=SQL_NONE, force=False): # If something went wrong, don't save inventory if revert: #db.rollback() - stdout("SQL.ERR: Error happened, commiting anyway due MyISAM...") + stdout("SQL.ERR: Error happened, commiting anyway due MyISAM...", 0) # We should now remove every item with an index higher than length # In case the inventory shrink without None's taking the place... w.execute("""DELETE FROM `inventory` WHERE `userid` = %d AND `index` >= %d""" % (uid, len(inv))) - stdout("SQL.INV: delete indexes >= %d, committing changes" % len(inv)) + stdout("SQL.INV: delete indexes >= %d, committing changes" % len(inv), 2) db.commit() w.close() @@ -190,10 +191,10 @@ def save_party(token, mask=SQL_NONE): Player[token]["party_%d" % i][3]["inv_id"], Player[token]["userid"], i) - stdout(sqlx) + stdout(sqlx, 2) w.execute(sqlx) except: - print("[SQL ERROR] Impossible to save party %d" % i) + stdout("[SQL ERROR] Impossible to save party %d" % i, 0) db.rollback() i+=1 @@ -354,7 +355,7 @@ def keep_alive(): db.ping(reconnect=True, attempts=10, delay=1) except: # SQL error - stdout("keep_alive: INTERNAL ERROR") + stdout("keep_alive: INTERNAL ERROR", 0) db.reconnect(attempts=12, delay=10) sql_keep_alive=threading.Timer(SQL_PINGTIME, keep_alive) sql_keep_alive.daemon=True |