def _setup_logfiles(self):
    from testplan.common.utils.logger import LOGFILE_FORMAT
    if (not os.path.exists(self.runpath)):
        os.makedirs(self.runpath)
    stderr_file = os.path.join(self.runpath, '{}_stderr'.format(self._metadata['index']))
    log_file = os.path.join(self.runpath, '{}_stdout'.format(self._metadata['index']))
    self.logger.info('stdout file = %(file)s (log level = %(lvl)s)', {'file': log_file, 'lvl': self.logger.level})
    self.logger.info('stderr file = %s', stderr_file)
    self.logger.info('Closing stdin, stdout and stderr file descriptors...')
    for fdesc in range(3):
        os.close(fdesc)
    mode = ('w' if platform.python_version().startswith('3') else 'wb')
    sys.stderr = open(stderr_file, mode)
    fhandler = logging.FileHandler(log_file, encoding='utf-8')
    formatter = logging.Formatter(LOGFILE_FORMAT)
    fhandler.setFormatter(formatter)
    fhandler.setLevel(self.logger.level)
    self.logger.addHandler(fhandler)
def _setup_logfiles(self):
    from testplan.common.utils.logger import LOGFILE_FORMAT
    if (not os.path.exists(self.runpath)):
        os.makedirs(self.runpath)
    stderr_file = os.path.join(self.runpath, '{}_stderr'.format(self._metadata['index']))
    log_file = os.path.join(self.runpath, '{}_stdout'.format(self._metadata['index']))
    self.logger.info('stdout file = %(file)s (log level = %(lvl)s)', {'file': log_file, 'lvl': self.logger.level})
    self.logger.info('stderr file = %s', stderr_file)
    self.logger.info('Closing stdin, stdout and stderr file descriptors...')
    for fdesc in range(3):
        os.close(fdesc)
    mode = ('w' if platform.python_version().startswith('3') else 'wb')
    sys.stderr = open(stderr_file, mode)
    fhandler = logging.FileHandler(log_file, encoding='utf-8')
    formatter = logging.Formatter(LOGFILE_FORMAT)
    fhandler.setFormatter(formatter)
    fhandler.setLevel(self.logger.level)
    self.logger.addHandler(fhandler)