Skip to content

Commit

Permalink
Stop including the origin module in Debug logs (#10642)
Browse files Browse the repository at this point in the history
Before:

```
20:28:40 [DEBUG] engine::externs::interface: File handle limit is: 20000
...
15:28:01 [DEBUG] workunit_store: Completed: pants.engine.internals.build_files.strip_address_origins
```

After:

```
20:28:40 [DEBUG] File handle limit is: 20000
...
15:28:01 [DEBUG] Completed: pants.engine.internals.build_files.strip_address_origins
```

[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano authored Aug 18, 2020
1 parent cfc48b0 commit d5801ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
18 changes: 0 additions & 18 deletions src/python/pants/testutil/pants_run_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import glob
import os
import re
import subprocess
import sys
import unittest
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/rust/engine/logging/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl<W: Write + Send + 'static> MaybeWriteLogger<W> {
.set_time_to_local(true)
.set_thread_level(LevelFilter::Off)
.set_level_padding(LevelPadding::Off)
.set_target_level(LevelFilter::Off)
.build();

MaybeWriteLogger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

0 comments on commit d5801ae

Please sign in to comment.