2022-12-11 23:44:34 +00:00
|
|
|
from files.helpers.config.const import LOG_DIRECTORY
|
2022-11-30 18:09:31 +00:00
|
|
|
|
2022-11-30 18:49:22 +00:00
|
|
|
def log_file(log_str: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:
|
|
|
|
with open(log_target, "a", encoding="utf-8") 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__}")
|