below is a function that takes in a message that prints the message to the console with the print statement, and also logs the message to a file by appending to it
def log(message):
timestamp = utcTimestamp()
print(f"{timestamp} {message}")
try:
with open(f"{logfile}", "a") as outfile:
outfile.write(f"{timestamp} {message}\n")
except Exception as err:
print(f"{timestamp} ERROR in log(): {err}")
return timestamp
However, a problem is that although the function is able to successfully write to a file when it is prompted, but the print statement seems not to be executed as there is not printed statements in the console. How do I solve the problem and also be able to see the print statements in the console?