Coverage for src / lexigram / contracts / core / logging.py: 0%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Logging protocols for Lexigram Framework.
3This module defines the standard logging interface used across the
4framework to avoid circular dependencies and allow sub-packages to
5remain independent of the concrete logging implementation.
6"""
8from __future__ import annotations
10from typing import Any, Protocol, runtime_checkable
13@runtime_checkable
14class LoggerProtocol(Protocol):
15 """Protocol for structured logging with context support."""
17 def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
18 def info(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
19 def warning(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
20 def error(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
21 def critical(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
22 def exception(self, msg: str, *args: Any, **kwargs: Any) -> None: ...
24 def bind(self, **kwargs: Any) -> LoggerProtocol:
25 """Add context variables to the logger."""
26 ...
28 def unbind(self, *keys: str) -> LoggerProtocol:
29 """Remove context variables from the logger."""
30 ...
33@runtime_checkable
34class LoggerFactoryProtocol(Protocol):
35 """Protocol for creating/retrieving named logger instances."""
37 def get_logger(self, name: str | None = None) -> LoggerProtocol:
38 """Get a logger instance for the given name."""
39 ...
42@runtime_checkable
43class RedactorProtocol(Protocol):
44 """Protocol for sensitive data redaction."""
46 def redact_dict(self, data: dict[str, Any]) -> dict[str, Any]:
47 """Return a copy of ``data`` with sensitive values masked."""
48 ...
50 def redact_value(self, value: Any) -> Any:
51 """Redact a single value if it matches a sensitive pattern."""
52 ...
55__all__ = ["LoggerFactoryProtocol", "LoggerProtocol", "RedactorProtocol"]