Coverage for src / ezpl / types / protocols / logger_protocol.py: 100.00%
3 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 19:35 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 19:35 +0000
1# ///////////////////////////////////////////////////////////////
2# EZPL - Logger Protocol
3# Project: ezpl
4# ///////////////////////////////////////////////////////////////
6"""
7Logger Protocol for Ezpl logging framework.
9This module defines the Protocol (abstract interface) that all logger
10implementations must follow. It provides type checking and ensures
11consistent API across different logger implementations.
12"""
14from __future__ import annotations
16# ///////////////////////////////////////////////////////////////
17# IMPORTS
18# ///////////////////////////////////////////////////////////////
19# Standard library imports
20from pathlib import Path
21from typing import Any, Protocol, runtime_checkable
23# ///////////////////////////////////////////////////////////////
24# PROTOCOLS
25# ///////////////////////////////////////////////////////////////
28@runtime_checkable
29class LoggerProtocol(Protocol):
30 """
31 Protocol defining the interface for logger implementations.
33 All logger implementations must conform to this protocol to ensure
34 consistent API and type safety.
36 **Required Methods:**
37 - Logging methods: info(), debug(), success(), warning(), warn(), error(), critical(), trace(), bind()
38 - Utility methods: set_level(), log(), add_separator()
39 - Getter methods: get_logger(), get_log_file()
41 **Note:**
42 This protocol is designed to be compatible with loguru.Logger
43 while allowing custom implementations.
44 """
46 # ///////////////////////////////////////////////////////////////
47 # CORE LOGGING METHODS (loguru-compatible)
48 # ///////////////////////////////////////////////////////////////
50 def trace(self, message: Any, *args, **kwargs) -> None:
51 """Log a trace message."""
52 ...
54 def debug(self, message: Any, *args, **kwargs) -> None:
55 """Log a debug message."""
56 ...
58 def info(self, message: Any, *args, **kwargs) -> None:
59 """Log an info message."""
60 ...
62 def success(self, message: Any, *args, **kwargs) -> None:
63 """Log a success message."""
64 ...
66 def warning(self, message: Any, *args, **kwargs) -> None:
67 """Log a warning message."""
68 ...
70 def warn(self, message: Any, *args, **kwargs) -> None:
71 """Alias for warning(). Log a warning message."""
72 ...
74 def error(self, message: Any, *args, **kwargs) -> None:
75 """Log an error message."""
76 ...
78 def critical(self, message: Any, *args, **kwargs) -> None:
79 """Log a critical message."""
80 ...
82 def exception(self, message: Any, *args, **kwargs) -> None:
83 """Log an exception with traceback."""
84 ...
86 # ///////////////////////////////////////////////////////////////
87 # LOGURU-SPECIFIC METHODS
88 # ///////////////////////////////////////////////////////////////
90 def bind(self, **kwargs: Any) -> Any:
91 """Bind context variables to the logger."""
92 ...
94 def opt(self, **kwargs: Any) -> Any:
95 """Configure logger options."""
96 ...
98 def patch(self, patcher: Any) -> Any:
99 """Patch log records."""
100 ...
102 # ///////////////////////////////////////////////////////////////
103 # EZPL-SPECIFIC METHODS
104 # ///////////////////////////////////////////////////////////////
106 @property
107 def level(self) -> str:
108 """Get the current logging level."""
109 ...
111 def set_level(self, level: str) -> None:
112 """Set the logging level."""
113 ...
115 def log(self, level: str, message: Any) -> None:
116 """Log a message with specified level."""
117 ...
119 def add_separator(self) -> None:
120 """Add a session separator to the log file."""
121 ...
123 def get_log_file(self) -> Path:
124 """Get the current log file path."""
125 ...
127 def close(self) -> None:
128 """Close the logger and release resources."""
129 ...