Skip to content

Commit 6132125

Browse files
committed
Use pydevd.log_to in debugpy to enable pydevd logging given the usage of debugpy.log_to. Fixes #1030
1 parent 3272dac commit 6132125

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/debugpy/server/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def ensure_logging():
5858
ensure_logging.ensured = True
5959
log.to_file(prefix="debugpy.server")
6060
log.describe_environment("Initial environment:")
61+
pydevd.log_to(log.log_dir + "/debugpy.pydevd.log")
6162

6263

6364
ensure_logging.ensured = False

tests/debugpy/test_log.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111

1212
@contextlib.contextmanager
13-
def check_logs(tmpdir, run, pydevd_log):
13+
def check_logs(tmpdir, run):
1414
# For attach_pid, there's ptvsd.server process that performs the injection,
1515
# and then there's the debug server that is injected into the debuggee.
1616
server_count = 2 if type(run).__name__ == "attach_pid" else 1
1717

1818
expected_logs = {
1919
"debugpy.adapter-*.log": 1,
2020
"debugpy.launcher-*.log": 1 if run.request == "launch" else 0,
21-
"debugpy.pydevd.*.log": server_count if pydevd_log else 0,
21+
"debugpy.pydevd.*.log": server_count,
2222
"debugpy.server-*.log": server_count,
2323
}
2424

@@ -43,7 +43,7 @@ def code_to_debug():
4343
# Depending on the method, the runner will use either `debugpy --log-dir ...`
4444
# or `debugpy.log_to() ...`.
4545
run = run.with_options(log_dir=tmpdir.strpath)
46-
with check_logs(tmpdir, run, pydevd_log=False):
46+
with check_logs(tmpdir, run):
4747
with debug.Session() as session:
4848
session.log_dir = None
4949

@@ -62,7 +62,7 @@ def code_to_debug():
6262
debuggee.setup()
6363
assert backchannel.receive() == "proceed"
6464

65-
with check_logs(tmpdir, run, pydevd_log=True):
65+
with check_logs(tmpdir, run):
6666
with debug.Session() as session:
6767
session.log_dir = None
6868
session.spawn_adapter.env["DEBUGPY_LOG_DIR"] = tmpdir.strpath

0 commit comments

Comments
 (0)