From 8702cdfa0025f6e53594ccc7aa0ec0700f1893ec Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 30 Jun 2022 17:07:31 +0200 Subject: [PATCH] Make logfile-directory if not already exists --- nafuma/auxillary.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nafuma/auxillary.py b/nafuma/auxillary.py index 0ccde1f..bf06f8e 100644 --- a/nafuma/auxillary.py +++ b/nafuma/auxillary.py @@ -77,6 +77,10 @@ def write_log(message, options={}): options = update_options(options=options, required_options=required_options, default_options=default_options) + if not os.path.isdir(os.path.dirname(options['logfile'])): + os.makedirs(os.path.dirname(options['logfile'])) + + now = datetime.now().strftime('%Y/%m/%d %H:%M:%S') message = f'[{now}] {message} \n'