Add opt-in debug logging across the CLI pipeline
Thread RP_DEBUG-driven logging through input, detection, rendering, and pager decisions so CLI behavior is inspectable without polluting stdout. Add focused coverage for debug wiring, env parsing, and stderr-only output.
This commit is contained in:
@@ -198,6 +198,30 @@ class TestGuessContent:
|
||||
assert detect_type(content=sample_json, guess_content=True) == "json"
|
||||
|
||||
|
||||
class TestDebugLogging:
|
||||
"""Debug logging describes inference decisions."""
|
||||
|
||||
def test_logs_extension_source(self) -> None:
|
||||
messages: list[str] = []
|
||||
|
||||
assert detect_type(path="script.py", debug=messages.append) == "python"
|
||||
assert messages == ["type: inferred 'python' from extension '.py'"]
|
||||
|
||||
def test_logs_content_guess_and_score(self) -> None:
|
||||
messages: list[str] = []
|
||||
diff = "--- a/file\n+++ b/file\n@@ -1 +1 @@\n-old\n+new\n"
|
||||
|
||||
assert (
|
||||
detect_type(content=diff, guess_content=True, debug=messages.append)
|
||||
== "diff"
|
||||
)
|
||||
assert any(
|
||||
"type: content guess -> lexer='diff', score=" in message
|
||||
for message in messages
|
||||
)
|
||||
assert "type: inferred 'diff' from heuristic content guessing" in messages
|
||||
|
||||
|
||||
class TestFallback:
|
||||
"""Priority 7: fallback to 'text'."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user