forked from rDrama/rDrama
1
0
Fork 0

logging: don't use \n in f-string

master
justcool393 2022-11-30 12:49:22 -06:00
parent d783bc8901
commit 497c9bcff1
1 changed files with 2 additions and 2 deletions

View File

@ -1,12 +1,12 @@
from files.helpers.const import LOG_DIRECTORY
def log_file(log_str:str, log_filename="rdrama.log", append_newline=True):
def log_file(log_str:str, log_filename="rdrama.log"):
'''
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:
f.write(f"{log_str}{'\n' if append_newline else ''}")
f.write(log_str + '\n')
except Exception as e:
print(f"Failed to log to file {log_target} due to {e.__class__.__name__}")