Skip to content

Instantly share code, notes, and snippets.

View prashantochatterjee's full-sized avatar

prashantochatterjee

View GitHub Profile
@jaketame
jaketame / logging_subprocess.py
Created April 28, 2017 13:05
Python subprocess logging to logger from stdout/stderr
#!/usr/local/bin/python3
import logging, select, subprocess
LOG_FILE = "test.log"
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO,filename=LOG_FILE,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
def logging_call(popenargs, **kwargs):
process = subprocess.Popen(popenargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)