Make level optional argument
This commit is contained in:
parent
3c65bc05b8
commit
aa7097e264
@ -13,7 +13,7 @@ class bcolors:
|
|||||||
BOLD = '\033[1m'
|
BOLD = '\033[1m'
|
||||||
UNDERLINE = '\033[4m'
|
UNDERLINE = '\033[4m'
|
||||||
|
|
||||||
def log(level, message, thread="", detail=True, write=True):
|
def log(message, level="i", thread="", detail=True, write=True):
|
||||||
global i
|
global i
|
||||||
message = f"{bcolors.OKCYAN}{message}{bcolors.ENDC}"
|
message = f"{bcolors.OKCYAN}{message}{bcolors.ENDC}"
|
||||||
if thread != "":
|
if thread != "":
|
||||||
|
29
test.py
29
test.py
@ -4,22 +4,21 @@ import os
|
|||||||
os.remove("logs/main.log")
|
os.remove("logs/main.log")
|
||||||
#Test 1
|
#Test 1
|
||||||
print("Everything should look like how you want it to.\n")
|
print("Everything should look like how you want it to.\n")
|
||||||
log("i", "Testing...")
|
log("Testing...", "i")
|
||||||
log("i", "I should have a thread listed.", "otherThread")
|
log("I should have a thread listed.", "i", "otherThread")
|
||||||
log("w", "Warning...")
|
log("Warning...", "w")
|
||||||
log("w", "I should have a thread listed.", "otherThread")
|
log("I should have a thread listed.", "w", "otherThread")
|
||||||
log("e", "Error!")
|
log("Error!", "e")
|
||||||
log("e", "I should have a thread listed.", "otherThread")
|
log("I should have a thread listed.", "e", "otherThread")
|
||||||
print("\nYou should stop seeing any details!\n")
|
print("\nYou should stop seeing any details!\n")
|
||||||
log("i", "Testing...", "", False)
|
log("Testing...", "i", "", False)
|
||||||
log("i", "I should have a thread listed.", "otherThread",False)
|
log("I should have a thread listed.", "i", "otherThread",False)
|
||||||
log("w", "Warning...", "", False)
|
log("Warning...", "w", "", False)
|
||||||
log("w", "I should have a thread listed.", "otherThread", False)
|
log("I should have a thread listed.", "w", "otherThread", False)
|
||||||
log("e", "Error!", "", False)
|
log("Error!", "e", "", False)
|
||||||
log("e", "I should have a thread listed.", "otherThread", False)
|
log("I should have a thread listed.", "e", "otherThread", False)
|
||||||
print("\nYou should not see the following in the log file!\n")
|
print("\nYou should not see the following in the log file!\n")
|
||||||
log("i", "I should not appear in the log file!", "", False, False)
|
log("I should not appear in the log file!", "i", "", False, False)
|
||||||
log("i", "I should not appear in the log file!", "", True, False)
|
log("I should not appear in the log file!", "i", "", True, False)
|
||||||
|
|
||||||
print("\nMake sure the log file doesn't have the above or any color codes!")
|
print("\nMake sure the log file doesn't have the above or any color codes!")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user