Moved files to subdirectory
This commit is contained in:
13
legacy/utils/logging/debug.py
Normal file
13
legacy/utils/logging/debug.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import main
|
||||
|
||||
|
||||
# we need a seperate module to log.py, as log.py is imported by main.py, and we need to access main
|
||||
# to read the setting
|
||||
def debug(*data):
|
||||
if main.config["Debug"]:
|
||||
print("[DEBUG]", *data)
|
||||
|
||||
|
||||
def trace(*data):
|
||||
if main.config["Trace"]:
|
||||
print("[TRACE]", *data)
|
||||
10
legacy/utils/logging/log.py
Normal file
10
legacy/utils/logging/log.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def log(*data):
|
||||
print("[LOG]", *data)
|
||||
|
||||
|
||||
def warn(*data):
|
||||
print("[WARNING]", *data)
|
||||
|
||||
|
||||
def error(*data):
|
||||
print("[ERROR]", *data)
|
||||
40
legacy/utils/logging/send.py
Normal file
40
legacy/utils/logging/send.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import main
|
||||
|
||||
|
||||
def sendData(addr, data):
|
||||
main.connections[addr].send(data)
|
||||
|
||||
|
||||
def sendWithPrefix(addr, data, prefix):
|
||||
toSend = ""
|
||||
for i in data.split("\n"):
|
||||
toSend += prefix + " " + i + "\n"
|
||||
sendData(addr, toSend)
|
||||
|
||||
|
||||
def sendSuccess(addr, data):
|
||||
sendWithPrefix(addr, data, "[y]")
|
||||
|
||||
|
||||
def sendFailure(addr, data):
|
||||
sendWithPrefix(addr, data, "[n]")
|
||||
|
||||
|
||||
def sendInfo(addr, data):
|
||||
sendWithPrefix(addr, data, "[i]")
|
||||
|
||||
|
||||
def sendAll(data):
|
||||
for i in main.connections:
|
||||
if main.connections[i].authed:
|
||||
main.connections[i].send(data)
|
||||
return
|
||||
|
||||
|
||||
def incorrectUsage(addr, mode):
|
||||
if mode is None:
|
||||
sendFailure(addr, "Incorrect usage")
|
||||
return
|
||||
if mode in main.help.keys():
|
||||
sendFailure(addr, "Usage: " + main.help[mode])
|
||||
return
|
||||
Reference in New Issue
Block a user