Commits

Marc-Alexandre Chan committed 36a527e

Fixed same log file error in DB driver class. Fixes issue 1.

Comments (0)

Files changed (1)

 from hashlib import sha512
 from datetime import datetime
 import logging
+from os import makedirs
+from os.path import isdir, dirname, realpath
 
 
 class TablePrefixer(DeclarativeMeta):
         self.base.metadata.bind = self.engine
 
         # set up logging
-        self._loghandler = logging.FileHandler(self._logfile, encoding='utf8')
+        real_logfile = realpath(self._logfile)
+        if not isdir(dirname(real_logfile)):
+            makedirs(dirname(real_logfile))
+        self._loghandler = logging.FileHandler(real_logfile, encoding='utf8')
         fmtr = logging.Formatter(kwargs.get('logformat',\
             '%(asctime)s (%(process)d:%(thread)d) '
             '[%(name)s:%(levelname)s] %(message)s'),\