Option C oc_diagnostics
Loading...
Searching...
No Matches
test_logging_handler Namespace Reference

Functions

logging.LogRecord _make_record (int level, str msg="test message")
 test_handler_emit_info ()
 test_handler_level_mapping ()
 test_handler_custom_domain ()
 test_handler_never_raises ()

Variables

 _REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))

Detailed Description

Regression Tests — logging_handler
====================================

Purpose
-------
Verify that ``OcDiagnosticsHandler`` correctly bridges Python's ``logging``
module into ``oc_diagnostics._dbg()``, including level mapping, custom domain
routing, and the non-raising contract on internal exceptions.

Responsibilities
----------------
- Confirm that ``OcDiagnosticsHandler.emit()`` routes a LogRecord without raising.
- Confirm the default level map: DEBUG→L4, INFO→L2, WARNING/ERROR/CRITICAL→L1.
- Confirm that the handler's ``domain`` argument is forwarded to ``_dbg()``.
- Confirm that internal exceptions are swallowed (delegated to ``handleError``).

Diagnostics
-----------
Domain: TEST
Levels:
    L2 — lifecycle
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- Must not permanently modify oc_diagnostics global state.
- Must not start servers or require network access.
- Must run deterministically across repeated invocations.

Function Documentation

◆ _make_record()

logging.LogRecord test_logging_handler._make_record ( int level,
str msg = "test message" )
protected
Build a minimal LogRecord for testing.

Definition at line 54 of file test_logging_handler.py.

Here is the caller graph for this function:

◆ test_handler_custom_domain()

test_logging_handler.test_handler_custom_domain ( )
Handler's domain argument is forwarded as the first positional arg to _dbg().

Definition at line 120 of file test_logging_handler.py.

Here is the call graph for this function:

◆ test_handler_emit_info()

test_logging_handler.test_handler_emit_info ( )
OcDiagnosticsHandler.emit() routes an INFO LogRecord through _dbg() without raising.

Definition at line 71 of file test_logging_handler.py.

Here is the call graph for this function:

◆ test_handler_level_mapping()

test_logging_handler.test_handler_level_mapping ( )
Default level map routes Python levels to oc_diagnostics levels correctly.

DEBUG→L4, INFO→L2, WARNING→L1, ERROR→L1, CRITICAL→L1.

Definition at line 87 of file test_logging_handler.py.

Here is the call graph for this function:

◆ test_handler_never_raises()

test_logging_handler.test_handler_never_raises ( )
OcDiagnosticsHandler.emit() must not propagate exceptions from _dbg().

Definition at line 138 of file test_logging_handler.py.

Here is the call graph for this function:

Variable Documentation

◆ _REPO_ROOT

test_logging_handler._REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
protected

Definition at line 46 of file test_logging_handler.py.