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

Classes

class  OcDiagnosticsHandler

Variables

dict _DEFAULT_LEVEL_MAP

Detailed Description

Python logging Handler
======================

Purpose
-------
Bridge the Python standard-library ``logging`` module into ``oc_diagnostics``
so that libraries and frameworks that emit log records via ``logging.getLogger``
are automatically captured and displayed through the unified diagnostics system.

Responsibilities
----------------
- Provide ``OcDiagnosticsHandler``, a ``logging.Handler`` subclass that
  converts each ``LogRecord`` to an ``oc_diagnostics._dbg()`` call.
- Map Python logging levels to oc_diagnostics diagnostic levels via a
  configurable ``level_map`` dict.
- Use a sensible default mapping:
    DEBUG    → L4 (deep tracing)
    INFO     → L2 (lifecycle)
    WARNING  → L1 (errors only)
    ERROR    → L1
    CRITICAL → L1

Diagnostics
-----------
Domain: configurable (default: "GENERAL")
Levels: determined by level_map at runtime

Contracts
---------
- Must not raise; errors are delegated to ``logging.Handler.handleError()``.
- Requires no optional dependencies (pure Python, always available).
- The ``domain`` and ``level_map`` are settable at construction time.

Variable Documentation

◆ _DEFAULT_LEVEL_MAP

dict oc_diagnostics.logging_handler._DEFAULT_LEVEL_MAP
protected
Initial value:
1= {
2 logging.DEBUG: 4,
3 logging.INFO: 2,
4 logging.WARNING: 1,
5 logging.ERROR: 1,
6 logging.CRITICAL: 1,
7}

Definition at line 46 of file logging_handler.py.