mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix: formatting of stdout, stderr captured text for logger
This commit is contained in:
@ -100,6 +100,7 @@ def _start_plot_process(gui_id: str, gui_class: type, config: dict | str, logger
|
|||||||
|
|
||||||
env_dict = os.environ.copy()
|
env_dict = os.environ.copy()
|
||||||
env_dict["PYTHONUNBUFFERED"] = "1"
|
env_dict["PYTHONUNBUFFERED"] = "1"
|
||||||
|
|
||||||
if logger is None:
|
if logger is None:
|
||||||
stdout_redirect = subprocess.DEVNULL
|
stdout_redirect = subprocess.DEVNULL
|
||||||
stderr_redirect = subprocess.DEVNULL
|
stderr_redirect = subprocess.DEVNULL
|
||||||
|
@ -130,15 +130,15 @@ class BECWidgetsCLIServer:
|
|||||||
class SimpleFileLikeFromLogOutputFunc:
|
class SimpleFileLikeFromLogOutputFunc:
|
||||||
def __init__(self, log_func):
|
def __init__(self, log_func):
|
||||||
self._log_func = log_func
|
self._log_func = log_func
|
||||||
|
self._buffer = []
|
||||||
|
|
||||||
def write(self, buffer):
|
def write(self, buffer):
|
||||||
for line in buffer.rstrip().splitlines():
|
self._buffer.append(buffer)
|
||||||
line = line.rstrip()
|
|
||||||
if line:
|
|
||||||
self._log_func(line)
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
return
|
lines, _, remaining = "".join(self._buffer).rpartition("\n")
|
||||||
|
self._log_func(lines)
|
||||||
|
self._buffer = [remaining]
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user