]> git.ipfire.org Git - people/jschlag/nitsi.git/commitdiff
Support also a file as base for the log file dir
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 21 Jun 2018 07:52:21 +0000 (09:52 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 21 Jun 2018 07:52:21 +0000 (09:52 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/nitsi/logger.py

index 4868fdab056107ab456231d37da21d25516fb6dc..37b19c24d282a1476ff28c83485ff96cdad17116 100644 (file)
@@ -13,15 +13,17 @@ class Logger_Exeception(BaseException):
 # and touch the logging files
 def init_logging(path):
     logger.debug("Init logging directory")
-    if not os.path.isdir(path):
-        logger.error("{} is not a valid directory".format(path))
 
     try:
         path = os.path.abspath(path)
     except BaseException as e:
         logger.error("Failed to get the absolute path for: {}".format(path))
 
-    log_dir = "{}/log".format(path)
+    if os.path.isdir(path):
+        log_dir = "{}/log".format(path)
+    elif os.path.isfile(path):
+        log_dir = "{}/{}.log".format(os.path.dirname(path), os.path.basename(path))
+
 
     if not os.path.exists(log_dir):
         os.mkdir(log_dir)