aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/utils/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/python/utils/__init__.py b/python/utils/__init__.py
index f186a8b2..3e5a0de1 100644
--- a/python/utils/__init__.py
+++ b/python/utils/__init__.py
@@ -11,7 +11,11 @@ class SerenitasFileHandler(logging.FileHandler):
)
def __init__(self, log_file):
- super().__init__(filename=os.path.join(os.getenv("LOG_DIR"), log_file))
+ if "LOG_DIR" not in os.environ:
+ base_dir = os.path.expanduser("~")
+ else:
+ base_dir = os.getenv("LOG_DIR")
+ super().__init__(filename=os.path.join(base_dir, log_file))
self.setFormatter(SerenitasFileHandler._formatter)
@@ -19,8 +23,12 @@ class SerenitasRotatingFileHandler(logging.handlers.RotatingFileHandler):
"""simple class that encapsulates where we store our logs"""
def __init__(self, log_file, maxBytes=0, backupCount=0):
+ if "LOG_DIR" not in os.environ:
+ base_dir = os.path.expanduser("~")
+ else:
+ base_dir = os.getenv("LOG_DIR")
super().__init__(
- filename=os.path.join(os.getenv("LOG_DIR"), log_file),
+ filename=os.path.join(base_dir, log_file),
maxBytes=maxBytes,
backupCount=backupCount,
)