Skip to content

Commit

Permalink
process log enabled only for logging.DEBUG #92 #93
Browse files Browse the repository at this point in the history
  • Loading branch information
ponty committed Feb 19, 2024
1 parent 1d03358 commit 27c4c85
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pyvirtualdisplay/abstractdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,30 @@ def start(self):
self._redirect_display(True)
self._reset_global_env = True

def _proc_log_enabled(self):
# process log is enabled only for logging.DEBUG
log.isEnabledFor(logging.DEBUG)

def _popen(self, use_pass_fds):
if self._proc_log_enabled():
stdout_stderr = subprocess.PIPE
else:
stdout_stderr = subprocess.DEVNULL

with _mutex_popen:
if use_pass_fds:
self._subproc = subprocess.Popen(
self._command,
pass_fds=[self._pipe_wfd],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=stdout_stderr,
stderr=stdout_stderr,
shell=False,
)
else:
self._subproc = subprocess.Popen(
self._command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=stdout_stderr,
stderr=stdout_stderr,
shell=False,
)

Expand Down Expand Up @@ -366,11 +375,12 @@ def stop(self):
return self

def _read_stdout_stderr(self):
if self.stdout is None:
(self.stdout, self.stderr) = self._subproc.communicate()
if self._proc_log_enabled():
if self.stdout is None:
(self.stdout, self.stderr) = self._subproc.communicate()

log.debug("stdout=%s", self.stdout)
log.debug("stderr=%s", self.stderr)
log.debug("stdout=%s", self.stdout)
log.debug("stderr=%s", self.stderr)

def _setup_xauth(self):
"""
Expand Down

0 comments on commit 27c4c85

Please sign in to comment.