Home / Function/ test_logging() — langchain Function Reference

test_logging() — langchain Function Reference

Architecture documentation for the test_logging() function in test_logging.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  cb407ac4_afdd_a7c9_31cc_695fa2b48cd2["test_logging()"]
  921d9b36_02e3_7d6e_0430_9c870f589460["test_logging.py"]
  cb407ac4_afdd_a7c9_31cc_695fa2b48cd2 -->|defined in| 921d9b36_02e3_7d6e_0430_9c870f589460
  style cb407ac4_afdd_a7c9_31cc_695fa2b48cd2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/callbacks/tracers/test_logging.py lines 10–38

def test_logging(
    caplog: pytest.LogCaptureFixture,
    capsys: pytest.CaptureFixture[str],
) -> None:
    # Set up a Logger and a handler so we can check the Logger's handlers work too
    logger = logging.getLogger("test_logging")
    logger.setLevel(logging.INFO)
    logger.addHandler(logging.StreamHandler(sys.stdout))

    handler = LoggingCallbackHandler(logger, extra={"test": "test_extra"})
    handler.on_text("test", run_id=uuid.uuid4())

    # Assert logging actually took place
    assert len(caplog.record_tuples) == 1
    record = caplog.records[0]
    assert record.name == logger.name
    assert record.levelno == logging.INFO
    assert (
        record.msg == "\x1b[36;1m\x1b[1;3m[text]\x1b[0m \x1b[1mNew text:\x1b[0m\ntest"
    )
    # Check the extra shows up
    assert record.test == "test_extra"  # type: ignore[attr-defined]

    # Assert log handlers worked
    cap_result = capsys.readouterr()
    assert (
        cap_result.out
        == "\x1b[36;1m\x1b[1;3m[text]\x1b[0m \x1b[1mNew text:\x1b[0m\ntest\n"
    )

Domain

Subdomains

Frequently Asked Questions

What does test_logging() do?
test_logging() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/callbacks/tracers/test_logging.py.
Where is test_logging() defined?
test_logging() is defined in libs/langchain/tests/unit_tests/callbacks/tracers/test_logging.py at line 10.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free