Merge pull request 'feat(log): ensure parent directory exists before opening log file' (#5) from refactor/logging into dev
Reviewed-on: freeleaps/freeleaps-service-hub#5
This commit is contained in:
commit
ecad36ac5c
@ -17,6 +17,10 @@ class JsonSink:
|
|||||||
self._open_log_file()
|
self._open_log_file()
|
||||||
|
|
||||||
def _open_log_file(self):
|
def _open_log_file(self):
|
||||||
|
# ensure the parent directory exists
|
||||||
|
parent_dir = self.log_file_path.parent
|
||||||
|
if not parent_dir.exists():
|
||||||
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
||||||
|
|
||||||
def _should_rotate(self) -> bool:
|
def _should_rotate(self) -> bool:
|
||||||
|
|||||||
@ -17,6 +17,10 @@ class JsonSink:
|
|||||||
self._open_log_file()
|
self._open_log_file()
|
||||||
|
|
||||||
def _open_log_file(self):
|
def _open_log_file(self):
|
||||||
|
# ensure the parent directory exists
|
||||||
|
parent_dir = self.log_file_path.parent
|
||||||
|
if not parent_dir.exists():
|
||||||
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
||||||
|
|
||||||
def _should_rotate(self) -> bool:
|
def _should_rotate(self) -> bool:
|
||||||
|
|||||||
@ -17,6 +17,10 @@ class JsonSink:
|
|||||||
self._open_log_file()
|
self._open_log_file()
|
||||||
|
|
||||||
def _open_log_file(self):
|
def _open_log_file(self):
|
||||||
|
# ensure the parent directory exists
|
||||||
|
parent_dir = self.log_file_path.parent
|
||||||
|
if not parent_dir.exists():
|
||||||
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
||||||
|
|
||||||
def _should_rotate(self) -> bool:
|
def _should_rotate(self) -> bool:
|
||||||
|
|||||||
@ -17,6 +17,10 @@ class JsonSink:
|
|||||||
self._open_log_file()
|
self._open_log_file()
|
||||||
|
|
||||||
def _open_log_file(self):
|
def _open_log_file(self):
|
||||||
|
# ensure the parent directory exists
|
||||||
|
parent_dir = self.log_file_path.parent
|
||||||
|
if not parent_dir.exists():
|
||||||
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
||||||
|
|
||||||
def _should_rotate(self) -> bool:
|
def _should_rotate(self) -> bool:
|
||||||
|
|||||||
@ -17,6 +17,10 @@ class JsonSink:
|
|||||||
self._open_log_file()
|
self._open_log_file()
|
||||||
|
|
||||||
def _open_log_file(self):
|
def _open_log_file(self):
|
||||||
|
# ensure the parent directory exists
|
||||||
|
parent_dir = self.log_file_path.parent
|
||||||
|
if not parent_dir.exists():
|
||||||
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
self.log_file = self.log_file_path.open("a", encoding="utf-8")
|
||||||
|
|
||||||
def _should_rotate(self) -> bool:
|
def _should_rotate(self) -> bool:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user