Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ddtrace/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def _configure_ddtrace_native_logger():
from .settings._config import config

if config._trace_writer_native:
backend = get_config("_DD_NATIVE_LOGGING_BACKEND", "file", report_telemetry=True)
backend = get_config("_DD_NATIVE_LOGGING_BACKEND", report_telemetry=True)
if not backend:
return
kwargs = {"output": backend}
if backend == "file":
kwargs["path"] = get_config("_DD_NATIVE_LOGGING_FILE_PATH", "native.log", report_telemetry=True)
Expand Down
8 changes: 6 additions & 2 deletions tests/tracer/test_native_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_logger_configure(output, path, files, max_bytes):
cases = [(config, msg, LEVELS.index(msg) >= LEVELS.index(config)) for config in LEVELS for msg in LEVELS]


@pytest.mark.parametrize("backend", ["stdout", "stderr", "file"])
@pytest.mark.parametrize("backend", ["", "stdout", "stderr", "file"])
@pytest.mark.parametrize("configured_level, message_level, should_log", cases)
def test_logger_subprocess(
backend, configured_level, message_level, should_log, tmp_path, ddtrace_run_python_code_in_subprocess
Expand All @@ -93,7 +93,11 @@ def test_logger_subprocess(
out, err, status, _ = ddtrace_run_python_code_in_subprocess(code, env=env)

assert status == 0
if backend == "stdout":
if backend == "":
assert out == b""
assert err == b""
assert not log_path.exists()
elif backend == "stdout":
found = message in out.decode("utf8")
assert err == b""
assert found == should_log
Expand Down
Loading