From af5b6df0048263161bb5c9c95cac75c0930cb126 Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Thu, 21 Jun 2018 09:52:21 +0200 Subject: [PATCH] Support also a file as base for the log file dir Signed-off-by: Jonatan Schlag --- src/nitsi/logger.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nitsi/logger.py b/src/nitsi/logger.py index 4868fda..37b19c2 100644 --- a/src/nitsi/logger.py +++ b/src/nitsi/logger.py @@ -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) -- 2.39.2