From aa7097e264ced16a62bae5bd7203ee7a989deb5b Mon Sep 17 00:00:00 2001 From: James Hoffman Date: Fri, 5 Apr 2024 09:49:49 -0600 Subject: [PATCH] Make level optional argument --- simpleLog.py | 2 +- test.py | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/simpleLog.py b/simpleLog.py index ed144f2..ada092f 100644 --- a/simpleLog.py +++ b/simpleLog.py @@ -13,7 +13,7 @@ class bcolors: BOLD = '\033[1m' UNDERLINE = '\033[4m' -def log(level, message, thread="", detail=True, write=True): +def log(message, level="i", thread="", detail=True, write=True): global i message = f"{bcolors.OKCYAN}{message}{bcolors.ENDC}" if thread != "": diff --git a/test.py b/test.py index c17c20a..9f4527a 100644 --- a/test.py +++ b/test.py @@ -4,22 +4,21 @@ import os os.remove("logs/main.log") #Test 1 print("Everything should look like how you want it to.\n") -log("i", "Testing...") -log("i", "I should have a thread listed.", "otherThread") -log("w", "Warning...") -log("w", "I should have a thread listed.", "otherThread") -log("e", "Error!") -log("e", "I should have a thread listed.", "otherThread") +log("Testing...", "i") +log("I should have a thread listed.", "i", "otherThread") +log("Warning...", "w") +log("I should have a thread listed.", "w", "otherThread") +log("Error!", "e") +log("I should have a thread listed.", "e", "otherThread") print("\nYou should stop seeing any details!\n") -log("i", "Testing...", "", False) -log("i", "I should have a thread listed.", "otherThread",False) -log("w", "Warning...", "", False) -log("w", "I should have a thread listed.", "otherThread", False) -log("e", "Error!", "", False) -log("e", "I should have a thread listed.", "otherThread", False) +log("Testing...", "i", "", False) +log("I should have a thread listed.", "i", "otherThread",False) +log("Warning...", "w", "", False) +log("I should have a thread listed.", "w", "otherThread", False) +log("Error!", "e", "", False) +log("I should have a thread listed.", "e", "otherThread", False) 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", "I should not appear in the log file!", "", True, False) +log("I should not appear in the log file!", "i", "", False, 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!") -