diff --git a/src/python/pants/testutil/pants_run_integration_test.py b/src/python/pants/testutil/pants_run_integration_test.py index 4cf18e2977c..b75d8bc1d0a 100644 --- a/src/python/pants/testutil/pants_run_integration_test.py +++ b/src/python/pants/testutil/pants_run_integration_test.py @@ -3,7 +3,6 @@ import glob import os -import re import subprocess import sys import unittest @@ -359,23 +358,6 @@ def indent(content): assertion(value, pants_run.returncode, error_msg) - def assert_run_contains_log(self, msg, level, module, pants_run: PantsResult): - """Asserts that the passed run's stderr contained the log message.""" - self.assert_contains_log(msg, level, module, pants_run.stderr_data, pants_run.pid) - - def assert_contains_log(self, msg, level, module, log, pid=None): - """Asserts that the passed log contains the message logged by the module at the level. - - If pid is specified, performs an exact match including the pid of the pants process. - Otherwise performs a regex match asserting that some pid is present. - """ - prefix = f"[{level}] {module}:pid=" - suffix = f": {msg}" - if pid is None: - self.assertRegex(log, re.escape(prefix) + r"\d+" + re.escape(suffix)) - else: - self.assertIn(f"{prefix}{pid}{suffix}", log) - @contextmanager def file_renamed(self, prefix, test_name, real_name): real_path = os.path.join(prefix, real_name) diff --git a/src/rust/engine/logging/src/logger.rs b/src/rust/engine/logging/src/logger.rs index e0e7dd05bfe..19dab25e977 100644 --- a/src/rust/engine/logging/src/logger.rs +++ b/src/rust/engine/logging/src/logger.rs @@ -243,6 +243,7 @@ impl MaybeWriteLogger { .set_time_to_local(true) .set_thread_level(LevelFilter::Off) .set_level_padding(LevelPadding::Off) + .set_target_level(LevelFilter::Off) .build(); MaybeWriteLogger { diff --git a/tests/python/pants_test/logging/native_engine_logging_integration_test.py b/tests/python/pants_test/logging/native_engine_logging_integration_test.py index a3abec1e002..5b30bc620b7 100644 --- a/tests/python/pants_test/logging/native_engine_logging_integration_test.py +++ b/tests/python/pants_test/logging/native_engine_logging_integration_test.py @@ -15,8 +15,8 @@ def use_pantsd_env_var(cls): """ return False - def test_native_logging(self): - expected_msg = r"\[DEBUG\] engine::scheduler: Launching \d+ root" + def test_native_logging(self) -> None: + expected_msg = r"\[DEBUG\] Launching \d+ root" pants_run = self.run_pants(["-linfo", "list", "3rdparty::"]) self.assertNotRegex(pants_run.stderr_data, expected_msg) @@ -25,19 +25,11 @@ def test_native_logging(self): class PantsdNativeLoggingTest(PantsDaemonIntegrationTestBase): - def test_pantsd_file_logging(self): + def test_pantsd_file_logging(self) -> None: with self.pantsd_successful_run_context("debug") as ctx: daemon_run = ctx.runner(["list", "3rdparty::"]) ctx.checker.assert_started() - - self.assert_run_contains_log( - "connecting to pantsd on port", - "DEBUG", - "pants.bin.remote_pants_runner", - daemon_run, - ) + assert "[DEBUG] connecting to pantsd on port" in daemon_run.stderr_data pantsd_log = "\n".join(read_pantsd_log(ctx.workdir)) - self.assert_contains_log( - "logging initialized", "DEBUG", "pants.pantsd.pants_daemon", pantsd_log, - ) + assert "[DEBUG] logging initialized" in pantsd_log