Added a message function

This commit is contained in:
dandaedre 2022-02-22 23:43:09 +01:00
parent c435e968a2
commit 578a01b1c7
1 changed files with 14 additions and 0 deletions

View File

@ -36,6 +36,20 @@ def initlogging(filename=None, loglevel="ERROR", filemode='w', handler=None):
logging.basicConfig(level=logging.__getattribute__(loglevel), handlers=handler)
def log_message(message, level="ERROR"):
"""
Logs a message
:param message: The message to log
:param level: The level of the message
:type level: str
:return: None
"""
level = level.lower()
logging.__getattribute__(level)(message)
if level in ["critical"]:
print("An unrecoverable error occurred, please check the log file for more information.")
def log_exception(exception, level="ERROR"):
"""
Logs an exception