I have a flask server running in background i.e. created a .service file and initiated the flask application. Now, when I fire flask APIs from launcher file, I am unable to see logger messages on console.
I am doing this to add verbosity option to my launcher for example if user gives "launcher.py -v", it should print INFO, ERROR, WARN and DEBUG messages.
I am new to python and went through documentation as well, couldn't figure out a way. Can someone suggest the right way to do this ?
Note: If I launch the application normally, I can see output on console as I have added StreamHandler(sys.out) to logger.
What I have tried:
I wrote below code to get the output to console, which is not the efficient way
#log_file is populated by flask logging i.e. fileHandler
pro = subprocess.Popen(["tail", "-n0", "-f", log_file])
#this is to terminate the process once launcher file exits
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)