From 795d46e37c63f408c3607ee91b738cdf52ba2dc3 Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Tue, 4 Aug 2026 01:00:25 +0500 Subject: [PATCH 1/2] fix: use logger instead of print() for error/warning messages in events.py Replace print(..., file=sys.stderr) calls with logger.error()/warning() for consistent logging behavior. The module already defines logger = logging.getLogger(__name__) and uses it elsewhere, but three messages were using print() which bypasses logging configuration. --- src/specify_cli/events.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/specify_cli/events.py b/src/specify_cli/events.py index d3002fe805..a3635fc268 100644 --- a/src/specify_cli/events.py +++ b/src/specify_cli/events.py @@ -276,10 +276,10 @@ def _run_inline(command_name, payload, project_root, timeout): return result.returncode return 0 except subprocess.TimeoutExpired: - print(f"Event {command_name} timed out", file=sys.stderr) + logger.error("Event %s timed out", command_name) return 2 except Exception as e: - print(f"Event {command_name} error: {e}", file=sys.stderr) + logger.error("Event %s error: %s", command_name, e) return 2 @@ -1070,9 +1070,8 @@ def install_integration_events( if ev in canonical_to_native: filtered[ev] = handlers else: - print( - f"\u26a0\ufe0f {integration.key} does not support '{ev}' events; skipping", - file=sys.stderr, + logger.warning( + "%s does not support '%s' events; skipping", integration.key, ev, ) # #3: an empty resolved map (--events false, or override disabling events) From 91effd590b76e53ba475539dcbd92d620ca2f3f1 Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Fri, 2 Oct 2026 23:00:26 +0500 Subject: [PATCH 2/2] fix(events): retarget the logger conversion after the events package move The branch was opened against src/specify_cli/events.py, which upstream has since moved to src/specify_cli/events/__init__.py. Merging main let git carry the three print()-to-logger conversions into the new file: the timeout and error paths now log at ERROR, and the unsupported-event notice logs at WARNING instead of writing to stderr. test_unsupported_events_are_skipped asserted that notice on stderr via capsys, which pytest's stream capture does not see once the message goes through logging; it now asserts on caplog. Assisted-by: opencode (model: mimo-v2.6-flash-free, autonomous) --- tests/integrations/test_integration_vibe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integrations/test_integration_vibe.py b/tests/integrations/test_integration_vibe.py index c2189a4b84..6be90136f6 100644 --- a/tests/integrations/test_integration_vibe.py +++ b/tests/integrations/test_integration_vibe.py @@ -217,14 +217,14 @@ def test_wildcard_matcher_omitted(self, tmp_path): (hook,) = self._parse(tmp_path)["hooks"] assert "match" not in hook - def test_unsupported_events_are_skipped(self, tmp_path, capsys): + def test_unsupported_events_are_skipped(self, tmp_path, caplog): self._install(tmp_path, { "session_start": [{"command": "speckit.agent-context.update"}], "pre_tool_use": [{"command": "speckit.tdd.validate"}], }) hooks = self._parse(tmp_path)["hooks"] assert [h["type"] for h in hooks] == ["pre_tool"] - assert "does not support 'session_start'" in capsys.readouterr().err + assert "does not support 'session_start'" in caplog.text def test_multiple_handlers_get_unique_names(self, tmp_path): """Vibe drops duplicate hook names, so shared command stems must not collide."""