Code Cleanup
This commit is contained in:
parent
d2622e25e8
commit
fa34f8510d
13 changed files with 98 additions and 50 deletions
|
@ -1,10 +1,14 @@
|
|||
'''
|
||||
Provides some simple logging utility
|
||||
'''
|
||||
import datetime
|
||||
|
||||
path = "logs/log.txt"
|
||||
cleanup = open(path, "w+")
|
||||
cleanup.close()
|
||||
|
||||
def log(msg, log_type, mute):
|
||||
# Format: [DD.MM.YYYY HH:MM:SS] [<TYPE>] MESSAGE
|
||||
def log(msg: str, log_type: str, mute: bool):
|
||||
log = f"[{datetime.datetime.now().strftime('%d.%m.%Y %H:%M:%S')}] [{log_type.upper()}] {msg}"
|
||||
log_file = open(path, "a")
|
||||
log_file.write(log + "\n")
|
||||
|
@ -12,11 +16,11 @@ def log(msg, log_type, mute):
|
|||
if mute == False:
|
||||
print(log)
|
||||
|
||||
def info(msg, mute=False):
|
||||
def info(msg: str, mute: bool=False):
|
||||
log(msg, "info", mute)
|
||||
|
||||
def warning(msg, mute=False):
|
||||
def warning(msg: str, mute: bool=False):
|
||||
log(msg, "warning", mute)
|
||||
|
||||
def error(msg, mute=False):
|
||||
def error(msg: str, mute: bool=False):
|
||||
log(msg, "error", mute)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue