1 from pathlib
import Path
2 from logging
import FileHandler
3 from logging.handlers
import WatchedFileHandler
8 class CoretexFileHandler(WatchedFileHandler):
10 def reopenIfNeeded(self) -> None:
12 path = Path(self.baseFilename)
15 if not path.parent.exists():
16 path.parent.mkdir(parents =
True, exist_ok =
True)
18 super().reopenIfNeeded()
21 def createFileHandler(path: Path) -> FileHandler:
23 Creates a handler for writting logs to the file system
32 FileHandler -> if OS is Windows
33 WatchedFileHandler -> if OS is Unix based
36 if platform.system() ==
"Windows":
37 return FileHandler(path)
39 return CoretexFileHandler(path)