I've got 2 files main.py and infinit.py, like below:
main.py
#!/usr/bin/python
import logging
import subprocess
import sys
logging.basicConfig(level=logging.INFO)
def forever():
    cmd = [sys.executable, 'infinit.py']
    while 1:
        try:
            print 'running new instance of:'
            print ' '.join(cmd)
            popen = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                stderr=subprocess.PIPE, universal_newlines=True)
            for line in iter(popen.stderr.readline, ""):
                print line,
            for line in iter(popen.stdout.readline, ""):
                print line,
        except Exception as e:
            print 'Something bad happend'
            logging.error(e)
if __name__ == '__main__':
    forever()
infinit.py
#!/usr/bin/python
import logging
logging.basicConfig(level=logging.INFO)
i = 0
while 1:
    i += 1
    logging.info('i: {0}'.format(i))
    print i
I run main.py and I want to see both (printing and logging ) in my console. I also want it to run on windows and linux. Additionally is it possible that it works (printing and logging) in windows Idle?
 
     
    