I am trying to log whatever is printed in console to a file(It should print in both console and in a file).i am using a command, that is logging the output to a file, but i am facing two problems: 1. Not printing the output on console, printing directly to a file. 2. If i am using sleep command it did not work.Can anyone help me in this with python codes. Here is my code
import time
sys.stdout = open("for_posterity.txt", "a")
def main():
while True:
fun1()
fun2()
def fun1():
time.sleep(1)
print("inside fun 1")
def fun2():
time.sleep(1)
print("inside fun 2")
if __name__ == '__main__':
main()