massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / logging / handlers.pyi
1 import datetime
2 import http.client
3 import ssl
4 import sys
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
10
11 if sys.version_info >= (3, 7):
12     from queue import Queue, SimpleQueue
13 else:
14     from queue import Queue
15
16 DEFAULT_TCP_LOGGING_PORT: int
17 DEFAULT_UDP_LOGGING_PORT: int
18 DEFAULT_HTTP_LOGGING_PORT: int
19 DEFAULT_SOAP_LOGGING_PORT: int
20 SYSLOG_UDP_PORT: int
21 SYSLOG_TCP_PORT: int
22
23 class WatchedFileHandler(FileHandler):
24     dev: int  # undocumented
25     ino: int  # undocumented
26     if sys.version_info >= (3, 9):
27         def __init__(
28             self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
29         ) -> None: ...
30     else:
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: ...
34
35 class BaseRotatingHandler(FileHandler):
36     namer: Callable[[str], str] | None
37     rotator: Callable[[str, str], None] | None
38     if sys.version_info >= (3, 9):
39         def __init__(
40             self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ..., errors: str | None = ...
41         ) -> None: ...
42     else:
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: ...
46
47 class RotatingFileHandler(BaseRotatingHandler):
48     maxBytes: str  # undocumented
49     backupCount: int  # undocumented
50     if sys.version_info >= (3, 9):
51         def __init__(
52             self,
53             filename: StrPath,
54             mode: str = ...,
55             maxBytes: int = ...,
56             backupCount: int = ...,
57             encoding: str | None = ...,
58             delay: bool = ...,
59             errors: str | None = ...,
60         ) -> None: ...
61     else:
62         def __init__(
63             self,
64             filename: StrPath,
65             mode: str = ...,
66             maxBytes: int = ...,
67             backupCount: int = ...,
68             encoding: str | None = ...,
69             delay: bool = ...,
70         ) -> None: ...
71     def doRollover(self) -> None: ...
72     def shouldRollover(self, record: LogRecord) -> int: ...  # undocumented
73
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):
85         def __init__(
86             self,
87             filename: StrPath,
88             when: str = ...,
89             interval: int = ...,
90             backupCount: int = ...,
91             encoding: str | None = ...,
92             delay: bool = ...,
93             utc: bool = ...,
94             atTime: datetime.datetime | None = ...,
95             errors: str | None = ...,
96         ) -> None: ...
97     else:
98         def __init__(
99             self,
100             filename: StrPath,
101             when: str = ...,
102             interval: int = ...,
103             backupCount: int = ...,
104             encoding: str | None = ...,
105             delay: bool = ...,
106             utc: bool = ...,
107             atTime: datetime.datetime | None = ...,
108         ) -> 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
113
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: ...
129
130 class DatagramHandler(SocketHandler):
131     def makeSocket(self) -> socket: ...  # type: ignore
132
133 class SysLogHandler(Handler):
134     LOG_EMERG: int
135     LOG_ALERT: int
136     LOG_CRIT: int
137     LOG_ERR: int
138     LOG_WARNING: int
139     LOG_NOTICE: int
140     LOG_INFO: int
141     LOG_DEBUG: int
142
143     LOG_KERN: int
144     LOG_USER: int
145     LOG_MAIL: int
146     LOG_DAEMON: int
147     LOG_AUTH: int
148     LOG_SYSLOG: int
149     LOG_LPR: int
150     LOG_NEWS: int
151     LOG_UUCP: int
152     LOG_CRON: int
153     LOG_AUTHPRIV: int
154     LOG_FTP: int
155
156     if sys.version_info >= (3, 9):
157         LOG_NTP: int
158         LOG_SECURITY: int
159         LOG_CONSOLE: int
160         LOG_SOLCRON: int
161
162     LOG_LOCAL0: int
163     LOG_LOCAL1: int
164     LOG_LOCAL2: int
165     LOG_LOCAL3: int
166     LOG_LOCAL4: int
167     LOG_LOCAL5: int
168     LOG_LOCAL6: int
169     LOG_LOCAL7: int
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: ...
182
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: ...
189
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
201     def __init__(
202         self,
203         mailhost: str | tuple[str, int],
204         fromaddr: str,
205         toaddrs: str | list[str],
206         subject: str,
207         credentials: tuple[str, str] | None = ...,
208         secure: tuple[()] | tuple[str] | tuple[str, str] | None = ...,
209         timeout: float = ...,
210     ) -> None: ...
211     def getSubject(self, record: LogRecord) -> str: ...
212
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: ...
218
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: ...
225
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
233     def __init__(
234         self,
235         host: str,
236         url: str,
237         method: str = ...,
238         secure: bool = ...,
239         credentials: tuple[str, str] | None = ...,
240         context: ssl.SSLContext | None = ...,
241     ) -> 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
245
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: ...
250     else:
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: ...
255
256 class QueueListener:
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
261         def __init__(
262             self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ...
263         ) -> None: ...
264     else:
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: ...