Update tests/pynamics-logger.py
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#6: perf_smpl
|
#6: perf_smpl
|
||||||
#7: get_time
|
#7: get_time
|
||||||
#8: breakpoint
|
#8: breakpoint
|
||||||
|
verboseness = 7
|
||||||
lvldict = {
|
lvldict = {
|
||||||
0: "FATAL",
|
0: "FATAL",
|
||||||
1: "ALERT",
|
1: "ALERT",
|
||||||
@@ -22,18 +23,18 @@ stpwtchtime = StopWatch()
|
|||||||
stpwtchtime.pause()
|
stpwtchtime.pause()
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
self.time.reset()
|
stpwtchtime.reset()
|
||||||
self.time.resume()
|
stpwtchtime.resume()
|
||||||
|
|
||||||
def log(self, message, level, origin):
|
def log(self, message, level, origin):
|
||||||
if level <= self.verboseness:
|
if level <= verboseness:
|
||||||
ms = self.time.time()
|
ms = stpwtchtime.time()
|
||||||
timestamp = "{:02d}:{:02d}.{:03d}".format(
|
timestamp = "{:02d}:{:02d}.{:03d}".format(
|
||||||
(ms // 60000) % 60,
|
(ms // 60000) % 60,
|
||||||
(ms // 1000) % 60,
|
(ms // 1000) % 60,
|
||||||
ms % 1000
|
ms % 1000
|
||||||
)
|
)
|
||||||
label = self.lvldict.get(level, "UNKNOWN")
|
label = lvldict.get(level, "UNKNOWN")
|
||||||
padding = " " * (7 - len(label))
|
padding = " " * (7 - len(label))
|
||||||
print("[{}] {}{} [{}] {}".format(timestamp, label, padding, origin, message))
|
print("[{}] {}{} [{}] {}".format(timestamp, label, padding, origin, message))
|
||||||
|
|
||||||
@@ -50,9 +51,9 @@ def notice(self, message, origin): notify(message, 5, origin)
|
|||||||
def info(self, message, origin): notify(message, 6, origin)
|
def info(self, message, origin): notify(message, 6, origin)
|
||||||
def debug(self, message, origin): notify(message, 7, origin)
|
def debug(self, message, origin): notify(message, 7, origin)
|
||||||
def crash(self, message, origin):
|
def crash(self, message, origin):
|
||||||
sendCommand(3, 0, "program kinda crashed bc you suck at coding", origin)
|
sendCommand(3, 0, "uhhhh so the program kinda crashed sorry", origin)
|
||||||
raise FatalLoggerError("[FATAL] [{}] {}".format(origin, message))
|
raise FatalLoggerError("[FATAL] [{}] {}".format(origin, message))
|
||||||
sendCommand(0, 0, "hey you should probably know that your RAM is corrupted and you cant buy more because of the shortage. byeeeee", "test prgm")
|
sendCommand(0, 0, "hey you should probably know that your RAM is corrupted and you cant replace it because of the shortage. byeeeee", "test prgm")
|
||||||
sendCommand(0, 1, "UNRECOVERABLE PYTHON ERROR!!!!! Exiting gracefully... JUST KIDDING WHAT DID YOU THINK IT WAS GONNA DO", "test prgm")
|
sendCommand(0, 1, "UNRECOVERABLE PYTHON ERROR!!!!! Exiting gracefully... JUST KIDDING WHAT DID YOU THINK IT WAS GONNA DO", "test prgm")
|
||||||
sendCommand(0, 2, "so the program is running but it just started looping on the motor frying bit of your program.", "test prgm")
|
sendCommand(0, 2, "so the program is running but it just started looping on the motor frying bit of your program.", "test prgm")
|
||||||
sendCommand(0, 3, "syntax error, you failure!!!! use an error checker", "test prgm")
|
sendCommand(0, 3, "syntax error, you failure!!!! use an error checker", "test prgm")
|
||||||
|
|||||||
Reference in New Issue
Block a user