MarseyWorld/files/helpers/logging.py

13 lines
360 B
Python
Raw Normal View History

from files.helpers.config.const import *
2022-11-30 18:09:31 +00:00
2023-07-30 00:42:06 +00:00
def log_file(log_str, log_filename="rdrama.log"):
2022-11-30 18:09:31 +00:00
'''
Simple method to log a string to a file
'''
log_target = f"{LOG_DIRECTORY}/{log_filename}"
try:
2023-09-14 23:19:44 +00:00
with open(log_target, "a") as f:
2022-11-30 18:49:22 +00:00
f.write(log_str + '\n')
2022-11-30 18:09:31 +00:00
except Exception as e:
print(f"Failed to log to file {log_target} due to {e.__class__.__name__}")