From 3b5ad23443831fcfa2167d9ab5b4bee4abd6ceea Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Thu, 15 Aug 2024 10:40:50 -0400 Subject: [PATCH] just make a single log file --- CHANGELOG.md | 4 ++-- config.dev.ini | 1 + pioreactor/cli/pio.py | 8 ++++++-- pioreactor/cluster_management/__init__.py | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a6600b..3f388b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ - `pio logs` now includes the UI logs (if run on leader). - introduce a new od_reading config,`turn_off_leds_during_reading`, which enables / disables turning off the other LEDS during an OD snapshot. By default, it is set to 1 (enables). - - leader-only Pioreactors also have a `config_hostname.local` file now. - - a new top-level section in experiment profiles, `inputs`, allows you to define variables that can be used in expressions. This is useful if you are copy the same constant over an over again, and want a quick way to change it once. Example: + - leader-only Pioreactors also have a `config_.local` file now. + - a new top-level section in experiment profiles, `inputs`, allows you to define parameters that can be used in expressions. This is useful if you are copy the same constant over an over again, and want a quick way to change it once. Example: ``` inputs: diff --git a/config.dev.ini b/config.dev.ini index 0443d5c7..215ff2be 100644 --- a/config.dev.ini +++ b/config.dev.ini @@ -66,6 +66,7 @@ database=pioreactor.sqlite [logging] log_file=./pioreactor.log +ui_log_file=./pioreactor.log # See Python's logging module for possible values #TODO: move this to another section diff --git a/pioreactor/cli/pio.py b/pioreactor/cli/pio.py index 52c35028..61788b1f 100644 --- a/pioreactor/cli/pio.py +++ b/pioreactor/cli/pio.py @@ -86,13 +86,17 @@ def logs(n: int) -> None: """ log_file = config.config.get("logging", "log_file", fallback="/var/log/pioreactor.log") ui_log_file = ( - config.config.get("logging", "ui_log_file", fallback="/var/log/pioreactorui.log") + config.config.get("logging", "ui_log_file", fallback="/var/log/pioreactor.log") if am_I_leader() else "" ) + if log_file == ui_log_file: + log_files = [log_file] + else: + log_files = [log_file, ui_log_file] with subprocess.Popen( - ["tail", "-fqn", str(n), log_file, ui_log_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT + ["tail", "-fqn", str(n)] + log_files, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) as process: assert process.stdout is not None for line in process.stdout: diff --git a/pioreactor/cluster_management/__init__.py b/pioreactor/cluster_management/__init__.py index 36f6d857..240df3b6 100644 --- a/pioreactor/cluster_management/__init__.py +++ b/pioreactor/cluster_management/__init__.py @@ -111,7 +111,7 @@ def add_worker(hostname: str, password: str, version: str, model: str) -> None: r.raise_for_status() except HTTPErrorStatus: if r.status_code >= 500: - logger.error("Server error. Could not complete. See UI logs in /var/log/pioreactorui.log") + logger.error("Server error. Could not complete. See UI logs") else: logger.error(f"Did not add worker {hostname} to backend.") raise HTTPException(f"Did not add worker {hostname} to backend.") @@ -130,7 +130,7 @@ def remove_worker(hostname: str) -> None: r.raise_for_status() except HTTPErrorStatus: if r.status_code >= 500: - click.echo("Server error. Could not complete. See UI logs in /var/log/pioreactorui.log") + click.echo("Server error. Could not complete. See UI logs.") else: click.echo(f"Worker {hostname} not present to be removed. Check hostname.") click.Abort()