diff -r 91421eeb4426 -r 9fce700d42de borgend.py --- a/borgend.py Sun Jan 21 14:56:56 2018 +0000 +++ b/borgend.py Sun Jan 21 16:21:53 2018 +0000 @@ -1,33 +1,67 @@ #!/usr/local/bin/python3 import logging -from threading import Thread +from fifolog import FIFOHandler + +# +# Branding +# +appname="borgend" +appname_stylised="Borgend" + +# +# Logging configuration +# -logging.basicConfig(#filename='example.log', - #format='%(levelname)s:%(message)s', - level=logging.DEBUG) +loglevel=logging.DEBUG +logfmt="%(asctime)s:%(levelname)s:%(name)s:%(message)s" +fifolog_capacity=1000 +fifolog_level=logging.WARNING +fifolog_fmt="%(asctime)s:%(levelname)s:%(message)s" -logger=logging.getLogger(__name__) +# +# Setup logger +# + +logger=logging.getLogger(appname) +logger.setLevel(loglevel) +logger.propagate=True +fifolog=FIFOHandler(fifolog_capacity) +logger.addHandler(fifolog) +fifolog.setLevel(fifolog_level) +fifolog.setFormatter(logging.Formatter(fifolog_fmt)) -from backup import Backup -from config import settings -from queue import Queue -from ui import BorgendTray -import signal, os +if __name__=="__main__": + + import logging.handlers + import os + import config + + if not os.path.isdir(config.logs_dir): + os.makedirs(config.logs_dir) + + handler=logging.handlers.TimedRotatingFileHandler( + os.path.join(config.logs_dir, appname+'.log'), + when='D', interval=1) + handler.setFormatter(logging.Formatter(logfmt)) + logger.addHandler(handler) -backupconfigs=settings['backups'] -backups=[None]*len(backupconfigs); + from threading import Thread + from backup import Backup + from queue import Queue + from ui import BorgendTray + import signal, os -for i in range(len(backupconfigs)): - logger.info('Setting up backup set %d' % i) - backups[i]=Backup(i, backupconfigs[i]) - backups[i].schedule() + backupconfigs=config.settings['backups'] + backups=[None]*len(backupconfigs); -if __name__ == "__main__": - #print(settings) + for i in range(len(backupconfigs)): + logger.info('Setting up backup set %d' % i) + backups[i]=Backup(i, backupconfigs[i]) + backups[i].schedule() + tray=BorgendTray(backups); tray.run() - pass # # This shit is fucked, disables ^C etc., and threading doesn't seem to help