diff options
author | Daniel Silverstone <dsilvers+gitlab@digital-scurf.org> | 2021-06-09 07:07:49 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers+gitlab@digital-scurf.org> | 2021-06-09 07:07:49 +0000 |
commit | 8f729f785d324735bd451b5cb142f7b107386230 (patch) | |
tree | a6c17e4a1950a8f16a4589c916645d1e031ddc0e | |
parent | d5af6bd6bc7ee0329ae01749099bd8245bdc6f2d (diff) | |
parent | 3b5deb4dc34ea5e86bf0124ec96407877eec7882 (diff) | |
download | subplot-8f729f785d324735bd451b5cb142f7b107386230.tar.gz |
Merge branch 'daemon-output-logging' into 'main'
feat(lib/daemon.py): split stdout/stderr when logging into lines
Closes #197
See merge request subplot/subplot!177
-rw-r--r-- | share/python/lib/daemon.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/share/python/lib/daemon.py b/share/python/lib/daemon.py index 11f65bf..0b47fe9 100644 --- a/share/python/lib/daemon.py +++ b/share/python/lib/daemon.py @@ -166,10 +166,9 @@ def daemon_stop(ctx, path=None, args=None, name=None): signo = signal.SIGTERM this = ns[name] - data = open(this["stdout"]).read() - logging.debug(f"{name} stdout, before: {data!r}") - data = open(this["stderr"]).read() - logging.debug(f"{name} stderr, before: {data!r}") + + _daemon_log_long(f"{name} stdout, before:", open(this["stdout"]).read()) + _daemon_log_long(f"{name} stderr, before:", open(this["stderr"]).read()) logging.debug(f"Terminating process {pid} with signal {signo}") try: @@ -186,10 +185,14 @@ def daemon_stop(ctx, path=None, args=None, name=None): break logging.debug(f"Daemon {name} is gone") - data = open(this["stdout"]).read() - logging.debug(f"{name} stdout, after: {data!r}") - data = open(this["stderr"]).read() - logging.debug(f"{name} stderr, after: {data!r}") + _daemon_log_long(f"{name} stdout, after:", open(this["stdout"]).read()) + _daemon_log_long(f"{name} stderr, after:", open(this["stderr"]).read()) + + +def _daemon_log_long(prefix, data): + logging.debug(prefix) + for line in data.splitlines(): + logging.debug(f" {line}") def daemon_no_such_process(ctx, args=None): |