summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-04 15:26:49 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-04 15:26:49 -0300
commit27c66ba593683aa167d364964b5385b9a0d0bdd8 (patch)
tree3afec735589c26272e28acef0e79f8370fa5b392 /utils.py
parent00b6b129f1848613404ead84ef2754fd1f614b8a (diff)
downloadserver-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 'utils.py')
-rw-r--r--utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/utils.py b/utils.py
index c4f94c4..447eef9 100644
--- a/utils.py
+++ b/utils.py
@@ -21,8 +21,11 @@
import time, hashlib, datetime, uuid
import json, zlib, base64
-# Be verbose
-debug=True
+# Set server debug level
+# 0 - Production/Stable, Silent
+# 1 - Production/Unstable
+# 2 - Development/Debug
+debug=1
# Create a variable called "salt", which contains the token saltening sequence
s=open("salt.txt", "r")
@@ -77,8 +80,8 @@ def date_from_now():
def stdout(mx, verbose=1):
- print(mx)
if (debug >= verbose):
+ print(mx)
dfile=open("debug.txt", 'a')
dt=datetime.datetime.now().timetuple()
date="[%04d-%02d-%02d %02d:%02d:%02d]" % (dt[0], dt[1], dt[2], dt[3], dt[4], dt[5])
@@ -86,13 +89,13 @@ def stdout(mx, verbose=1):
dfile.close()
def compress(string):
- stdout("Compress: Received JSON data: %s" % (string))
+ stdout("Compress: Received JSON data: %s" % (string), 1)
sjs=json.dumps(string)
sjs=sjs.encode("ascii")
sjs=zlib.compress(sjs)
sjs=base64.b64encode(sjs)
sjs=sjs.decode("ascii")
- stdout("Compress: Sending base64+zlib JSON ASCII data: %s" % (sjs))
+ stdout("Compress: Sending base64+zlib JSON ASCII data: %s" % (sjs), 2)
return sjs
# Search for array[?][key]==search in an array of dicts