5 from _typeshed import StrPath
6 from collections.abc import Callable
7 from logging import FileHandler, Handler, LogRecord
8 from socket import SocketKind, socket
9 from typing import Any, ClassVar, Pattern
11 if sys.version_info >= (3, 7):
12 from queue import Queue, SimpleQueue
14 from queue import Queue
16 DEFAULT_TCP_LOGGING_PORT: int
17 DEFAULT_UDP_LOGGING_PORT: int
18 DEFAULT_HTTP_LOGGING_PORT: int
19 DEFAULT_SOAP_LOGGING_PORT: int
23 class WatchedFileHandler(FileHandler):
24 dev: int # undocumented
25 ino: int # undocumented
26 if sys.version_info >= (3, 9):
28 self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
31 def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ...
32 def _statstream(self) -> None: ... # undocumented
33 def reopenIfNeeded(self) -> None: ...
35 class BaseRotatingHandler(FileHandler):
36 namer: Callable[[str], str] | None
37 rotator: Callable[[str, str], None] | None
38 if sys.version_info >= (3, 9):
40 self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
43 def __init__(self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ...) -> None: ...
44 def rotation_filename(self, default_name: str) -> str: ...
45 def rotate(self, source: str, dest: str) -> None: ...
47 class RotatingFileHandler(BaseRotatingHandler):
48 maxBytes: str # undocumented
49 backupCount: int # undocumented
50 if sys.version_info >= (3, 9):
56 backupCount: int = ...,
57 encoding: str | None = ...,
59 errors: str | None = ...,
67 backupCount: int = ...,
68 encoding: str | None = ...,
71 def doRollover(self) -> None: ...
72 def shouldRollover(self, record: LogRecord) -> int: ... # undocumented
74 class TimedRotatingFileHandler(BaseRotatingHandler):
75 when: str # undocumented
76 backupCount: int # undocumented
77 utc: bool # undocumented
78 atTime: datetime.datetime | None # undocumented
79 interval: int # undocumented
80 suffix: str # undocumented
81 dayOfWeek: int # undocumented
82 rolloverAt: int # undocumented
83 extMatch: Pattern[str] # undocumented
84 if sys.version_info >= (3, 9):
90 backupCount: int = ...,
91 encoding: str | None = ...,
94 atTime: datetime.datetime | None = ...,
95 errors: str | None = ...,
103 backupCount: int = ...,
104 encoding: str | None = ...,
107 atTime: datetime.datetime | None = ...,
109 def doRollover(self) -> None: ...
110 def shouldRollover(self, record: LogRecord) -> int: ... # undocumented
111 def computeRollover(self, currentTime: int) -> int: ... # undocumented
112 def getFilesToDelete(self) -> list[str]: ... # undocumented
114 class SocketHandler(Handler):
115 host: str # undocumented
116 port: int | None # undocumented
117 address: tuple[str, int] | str # undocumented
118 sock: socket | None # undocumented
119 closeOnError: bool # undocumented
120 retryTime: float | None # undocumented
121 retryStart: float # undocumented
122 retryFactor: float # undocumented
123 retryMax: float # undocumented
124 def __init__(self, host: str, port: int | None) -> None: ...
125 def makeSocket(self, timeout: float = ...) -> socket: ... # timeout is undocumented
126 def makePickle(self, record: LogRecord) -> bytes: ...
127 def send(self, s: bytes) -> None: ...
128 def createSocket(self) -> None: ...
130 class DatagramHandler(SocketHandler):
131 def makeSocket(self) -> socket: ... # type: ignore
133 class SysLogHandler(Handler):
156 if sys.version_info >= (3, 9):
170 address: tuple[str, int] | str # undocumented
171 unixsocket: bool # undocumented
172 socktype: SocketKind # undocumented
173 ident: str # undocumented
174 append_nul: bool # undocumented
175 facility: int # undocumented
176 priority_names: ClassVar[dict[str, int]] # undocumented
177 facility_names: ClassVar[dict[str, int]] # undocumented
178 priority_map: ClassVar[dict[str, str]] # undocumented
179 def __init__(self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ...) -> None: ...
180 def encodePriority(self, facility: int | str, priority: int | str) -> int: ...
181 def mapPriority(self, levelName: str) -> str: ...
183 class NTEventLogHandler(Handler):
184 def __init__(self, appname: str, dllname: str | None = ..., logtype: str = ...) -> None: ...
185 def getEventCategory(self, record: LogRecord) -> int: ...
186 # TODO correct return value?
187 def getEventType(self, record: LogRecord) -> int: ...
188 def getMessageID(self, record: LogRecord) -> int: ...
190 class SMTPHandler(Handler):
191 mailhost: str # undocumented
192 mailport: int | None # undocumented
193 username: str | None # undocumented
194 # password only exists as an attribute if passed credentials is a tuple or list
195 password: str # undocumented
196 fromaddr: str # undocumented
197 toaddrs: list[str] # undocumented
198 subject: str # undocumented
199 secure: tuple[()] | tuple[str] | tuple[str, str] | None # undocumented
200 timeout: float # undocumented
203 mailhost: str | tuple[str, int],
205 toaddrs: str | list[str],
207 credentials: tuple[str, str] | None = ...,
208 secure: tuple[()] | tuple[str] | tuple[str, str] | None = ...,
209 timeout: float = ...,
211 def getSubject(self, record: LogRecord) -> str: ...
213 class BufferingHandler(Handler):
214 capacity: int # undocumented
215 buffer: list[LogRecord] # undocumented
216 def __init__(self, capacity: int) -> None: ...
217 def shouldFlush(self, record: LogRecord) -> bool: ...
219 class MemoryHandler(BufferingHandler):
220 flushLevel: int # undocumented
221 target: Handler | None # undocumented
222 flushOnClose: bool # undocumented
223 def __init__(self, capacity: int, flushLevel: int = ..., target: Handler | None = ..., flushOnClose: bool = ...) -> None: ...
224 def setTarget(self, target: Handler | None) -> None: ...
226 class HTTPHandler(Handler):
227 host: str # undocumented
228 url: str # undocumented
229 method: str # undocumented
230 secure: bool # undocumented
231 credentials: tuple[str, str] | None # undocumented
232 context: ssl.SSLContext | None # undocumented
239 credentials: tuple[str, str] | None = ...,
240 context: ssl.SSLContext | None = ...,
242 def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ...
243 if sys.version_info >= (3, 9):
244 def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented
246 class QueueHandler(Handler):
247 if sys.version_info >= (3, 7):
248 queue: SimpleQueue[Any] | Queue[Any] # undocumented
249 def __init__(self, queue: SimpleQueue[Any] | Queue[Any]) -> None: ...
251 queue: Queue[Any] # undocumented
252 def __init__(self, queue: Queue[Any]) -> None: ...
253 def prepare(self, record: LogRecord) -> Any: ...
254 def enqueue(self, record: LogRecord) -> None: ...
257 handlers: tuple[Handler] # undocumented
258 respect_handler_level: bool # undocumented
259 if sys.version_info >= (3, 7):
260 queue: SimpleQueue[Any] | Queue[Any] # undocumented
262 self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ...
265 queue: Queue[Any] # undocumented
266 def __init__(self, queue: Queue[Any], *handlers: Handler, respect_handler_level: bool = ...) -> None: ...
267 def dequeue(self, block: bool) -> LogRecord: ...
268 def prepare(self, record: LogRecord) -> Any: ...
269 def start(self) -> None: ...
270 def stop(self) -> None: ...
271 def enqueue_sentinel(self) -> None: ...
272 def handle(self, record: LogRecord) -> None: ...