|
3 | 3 | from abc import ABCMeta, abstractmethod |
4 | 4 | from threading import RLock |
5 | 5 | # from socket import socket |
6 | | -from typing import Dict, Tuple, Optional, Any, List |
| 6 | +from typing import Dict, Tuple, Optional, Any, List, Union, OrderedDict |
7 | 7 | # Third party modules |
8 | 8 | # Local modules |
9 | 9 | # Program |
| 10 | +class T_Logger(metaclass=ABCMeta): |
| 11 | + @abstractmethod |
| 12 | + def getChild(self, *name:str) -> T_Logger: ... |
| 13 | + @abstractmethod |
| 14 | + def isFiltered(self, levelID:Union[int, str]) -> bool: ... |
| 15 | + @abstractmethod |
| 16 | + def trace(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 17 | + @abstractmethod |
| 18 | + def debug(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 19 | + @abstractmethod |
| 20 | + def info(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 21 | + @abstractmethod |
| 22 | + def warn(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 23 | + @abstractmethod |
| 24 | + def warning(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 25 | + @abstractmethod |
| 26 | + def error(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 27 | + @abstractmethod |
| 28 | + def critical(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 29 | + @abstractmethod |
| 30 | + def fatal(self, message:str, *args:Any, **kwargs:Any) -> None: ... |
| 31 | + |
| 32 | +class T_Filter(metaclass=ABCMeta): |
| 33 | + keys:OrderedDict[str, T_Filter] |
| 34 | + fallbackLevel:int |
| 35 | + @abstractmethod |
| 36 | + def addLogger(self, k:str, v:T_Filter) -> T_Filter: ... |
| 37 | + @abstractmethod |
| 38 | + def setFallbackLevel(self, level:Union[int, str]) -> None: ... |
| 39 | + @abstractmethod |
| 40 | + def getKey(self, k:str) -> Optional[T_Filter]: ... |
| 41 | + @abstractmethod |
| 42 | + def getFilteredID(self, path:List[str]) -> int: ... |
| 43 | + @abstractmethod |
| 44 | + def dump(self) -> List[Any]: ... |
| 45 | + @abstractmethod |
| 46 | + def extend(self, inp:T_Filter) -> None: ... |
| 47 | + |
10 | 48 | class T_LoggerManager(metaclass=ABCMeta): |
11 | 49 | lock:RLock |
12 | | - handler:Optional[T_LoggerManager] |
13 | 50 | filterChangeTime:float |
14 | 51 | groupSeperator:str |
| 52 | + handler:Optional[T_LoggerManager] |
| 53 | + filter:T_Filter |
| 54 | + delta:float |
| 55 | + messageFormat:str |
| 56 | + dateFormat:str |
15 | 57 | modules:List[T_ModuleBase] |
16 | 58 | @abstractmethod |
| 59 | + def getFilterData(self, name:str) -> Tuple[float, int]: ... |
| 60 | + @abstractmethod |
| 61 | + def emit(self, name:str, levelID:int, timestamp:float, message:Any, _args:Tuple[Any, ...], |
| 62 | + _kwargs:Dict[str, Any]) -> None: ... |
| 63 | + @abstractmethod |
| 64 | + def extendFilter(self, data:Union[List[Any], str, T_Filter]) -> None: ... |
| 65 | + @abstractmethod |
17 | 66 | def close(self, ) -> None: ... |
18 | 67 | @abstractmethod |
19 | | - def emit(self, name:str, levelID:int, timestamp:float, message:Any, _args:Tuple[Any, ...], _kwargs:Dict[str, Any]) -> None: ... |
| 68 | + def messageFormatter(self, name:str, levelID:int, timestamp:float, message:str, _args:Tuple[Any, ...], |
| 69 | + _kwargs:Dict[str, Any], datetime:Any=...) -> str: ... |
20 | 70 | @abstractmethod |
21 | | - def getFilterData(self, name:str) -> Tuple[float, int]: ... |
| 71 | + def initStandardOutStream(self) -> None: ... |
| 72 | + @abstractmethod |
| 73 | + def initFileStream(self, fullPath:str) -> None: ... |
| 74 | + @abstractmethod |
| 75 | + def initRotatedFileStream(self, fullPath:str, maxBytes:int=..., rotateDaily:bool=..., |
| 76 | + maxBackup:Optional[int]=...) -> None: ... |
| 77 | + @abstractmethod |
| 78 | + def initDailyFileStream(self, logPath:str, prefix:str, postfix:str, dateFormat:str=...) -> None: ... |
22 | 79 |
|
23 | 80 | class T_ModuleBase(metaclass=ABCMeta): |
24 | 81 | @abstractmethod |
|
0 commit comments