From: Jonatan Schlag Date: Thu, 21 Jun 2018 07:52:21 +0000 (+0200) Subject: Support also a file as base for the log file dir X-Git-Url: http://git.ipfire.org/?p=people%2Fjschlag%2Fnitsi.git;a=commitdiff_plain;h=af5b6df0048263161bb5c9c95cac75c0930cb126 Support also a file as base for the log file dir Signed-off-by: Jonatan Schlag --- 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)