check log destination dir

This commit is contained in:
petrucci4prez 2017-05-23 01:36:25 -04:00
parent aa1ea0e8de
commit cb15250efd
1 changed files with 9 additions and 2 deletions

View File

@ -58,8 +58,15 @@ class MasterLogger():
console = logging.StreamHandler() console = logging.StreamHandler()
console.setFormatter(consoleFormat) console.setFormatter(consoleFormat)
# TODO: check that 'logs' actually exists in the mp logdest = mountpoint + '/logs'
self.rotatingFile = TimedRotatingFileHandler(mountpoint + '/logs/pyledriver-log', when='midnight')
if not os.path.exists(logdest):
os.mkdir(logdest)
elif os.path.isfile(logdest):
fallbackLogger(__name__, 'CRITICAL', '{} is present but is a file (vs a directory). Please (re)move this file to prevent data loss'.format(logdest))
sys.exit()
self.rotatingFile = TimedRotatingFileHandler(logdest + '/pyledriver-log', when='midnight')
self.rotatingFile.setFormatter(fileFormat) self.rotatingFile.setFormatter(fileFormat)
logging.basicConfig(level=getattr(logging, level), handlers=[QueueHandler(queue)]) logging.basicConfig(level=getattr(logging, level), handlers=[QueueHandler(queue)])