2026-07-29 07:46:19 +03:00
|
|
|
#######################
|
|
|
|
|
# Sinmple Logging Lib #
|
|
|
|
|
#######################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# DESIGN TAGS:
|
|
|
|
|
# L -> Label
|
|
|
|
|
# X -> Name/Icon
|
|
|
|
|
# - -> White space
|
|
|
|
|
# <> -> Mini progress bar
|
|
|
|
|
# l -> Log level
|
|
|
|
|
|
|
|
|
|
|
2026-07-29 08:23:15 +03:00
|
|
|
class LogDesign():
|
|
|
|
|
|
2026-07-29 08:46:57 +03:00
|
|
|
#RESET
|
2026-07-29 08:23:15 +03:00
|
|
|
RESET = "\033[0m"
|
|
|
|
|
#GREEN
|
|
|
|
|
COLOR1= "\033[32m"
|
|
|
|
|
#YELLOW
|
|
|
|
|
COLOR2 = "\033[33m"
|
|
|
|
|
#RED
|
|
|
|
|
COLOR3 = "\033[31m"
|
2026-07-29 07:46:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-02 23:42:45 +03:00
|
|
|
template = "[L--X---]l"
|
2026-07-29 08:23:15 +03:00
|
|
|
whitepace = " "
|
2026-08-02 23:42:45 +03:00
|
|
|
iconChar = "i"
|
2026-07-29 08:23:15 +03:00
|
|
|
|
|
|
|
|
logChar = whitepace
|
|
|
|
|
warnChar = "W"
|
2026-08-02 23:36:17 +03:00
|
|
|
errorChar = "E"
|
2026-07-29 08:23:15 +03:00
|
|
|
|
|
|
|
|
logColor = COLOR1
|
|
|
|
|
warnColor = COLOR2
|
2026-08-02 23:36:17 +03:00
|
|
|
errorColor = COLOR3
|
2026-07-29 08:23:15 +03:00
|
|
|
|
2026-07-29 07:46:19 +03:00
|
|
|
|
2026-07-29 08:23:15 +03:00
|
|
|
DSGN_BLKLIST = ["-","X","<",">","L"]
|
2026-07-29 07:46:19 +03:00
|
|
|
|
|
|
|
|
|
2026-08-03 16:16:59 +03:00
|
|
|
def match_chars(log_type: str, DesignObject=LogDesign, ShowLogLevel=False, logLevel=0) -> str:
|
|
|
|
|
|
2026-08-02 23:42:45 +03:00
|
|
|
out = ""
|
|
|
|
|
for char in DesignObject.template:
|
2026-08-03 16:16:59 +03:00
|
|
|
|
2026-08-02 23:42:45 +03:00
|
|
|
match char:
|
|
|
|
|
case "L":
|
2026-08-03 16:16:59 +03:00
|
|
|
match log_type:
|
|
|
|
|
case "Log":
|
|
|
|
|
out += DesignObject.logChar
|
2026-08-02 23:42:45 +03:00
|
|
|
case "l":
|
|
|
|
|
if ShowLogLevel: out += str(logLevel)
|
2026-08-03 16:16:59 +03:00
|
|
|
else: out += DesignObject.whitepace
|
2026-08-02 23:42:45 +03:00
|
|
|
case "-":
|
|
|
|
|
out += DesignObject.whitepace
|
|
|
|
|
case "X":
|
|
|
|
|
out += DesignObject.iconChar
|
|
|
|
|
case _:
|
|
|
|
|
out += char
|
|
|
|
|
|
2026-08-03 16:16:59 +03:00
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def log(logValue,logLevel=1,DesignObject=LogDesign,ShowLogLevel=False):
|
|
|
|
|
|
|
|
|
|
out = match_chars("Log", DesignObject, ShowLogLevel, logLevel)
|
|
|
|
|
|
|
|
|
|
out = DesignObject.logColor + out + DesignObject.RESET
|
|
|
|
|
print(out , logValue)
|
2026-07-29 07:46:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-29 08:23:15 +03:00
|
|
|
def warn(warnValue,warnLevel=1,DesignObject=LogDesign,ShowWarnLevel=False):
|
|
|
|
|
out = ""
|
|
|
|
|
for char in DesignObject.template:
|
2026-08-02 23:23:55 +03:00
|
|
|
|
|
|
|
|
match char:
|
|
|
|
|
case "L":
|
|
|
|
|
out += DesignObject.warnChar
|
|
|
|
|
case "l":
|
|
|
|
|
if ShowWarnLevel:out += str(warnLevel)
|
|
|
|
|
else:out += DesignObject.whitepace
|
|
|
|
|
case "-":
|
|
|
|
|
out += DesignObject.whitepace
|
2026-08-02 23:42:45 +03:00
|
|
|
case "X":
|
|
|
|
|
out += DesignObject.iconChar
|
2026-08-02 23:23:55 +03:00
|
|
|
case _:
|
|
|
|
|
out += char
|
|
|
|
|
|
|
|
|
|
|
2026-07-29 08:23:15 +03:00
|
|
|
out = DesignObject.warnColor + out + DesignObject.RESET
|
|
|
|
|
print(out , warnValue)
|
2026-07-29 07:46:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-29 08:46:57 +03:00
|
|
|
|
2026-08-02 23:42:45 +03:00
|
|
|
def err(warnValue,DesignObject=LogDesign):
|
2026-08-02 23:36:17 +03:00
|
|
|
out = ""
|
|
|
|
|
for char in DesignObject.template:
|
|
|
|
|
|
|
|
|
|
match char:
|
|
|
|
|
case "L":
|
|
|
|
|
out += DesignObject.errorChar
|
|
|
|
|
case "l":
|
2026-08-02 23:42:45 +03:00
|
|
|
out += DesignObject.whitepace
|
2026-08-02 23:36:17 +03:00
|
|
|
case "-":
|
|
|
|
|
out += DesignObject.whitepace
|
2026-08-02 23:42:45 +03:00
|
|
|
case "X":
|
|
|
|
|
out += DesignObject.iconChar
|
2026-08-02 23:36:17 +03:00
|
|
|
case _:
|
|
|
|
|
out += char
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out = DesignObject.errorColor + out + DesignObject.RESET
|
|
|
|
|
print(out , warnValue)
|
|
|
|
|
|
2026-07-29 08:46:57 +03:00
|
|
|
|