From c4476693c8b68299ba508737f70d853cee8c0b8a Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Sun, 28 Apr 2019 22:20:49 -0700 Subject: [PATCH] Make use of rbackup.logging --- bin/backupd | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/backupd b/bin/backupd index 806b77e..17f283f 100644 --- a/bin/backupd +++ b/bin/backupd @@ -14,8 +14,10 @@ by the backup script and TODO inspect python-daemon for use with this script """ +import argparse import daemon import logging +import rbackup.logging from rbackup.struct.repository import Repository @@ -36,24 +38,19 @@ def parse_cmdline_arguments(**kwargs): # ========== Logging Setup ========== -console_formatter = logging.Formatter(LOGFORMAT) syslog = logging.getLogger("rbackup") syslog.setLevel(logging.DEBUG) -stdout_handler = logging.StreamHandler(sys.stdout) -stdout_handler.setLevel(logging.INFO) -stdout_handler.setFormatter(console_formatter) -stdout_handler.addFilter(lambda record: record.levelno <= logging.INFO) - -stderr_handler = logging.StreamHandler(sys.stderr) -stderr_handler.setLevel(logging.WARNING) -stderr_handler.setFormatter(console_formatter) - -syslog.addHandler(stdout_handler) -syslog.addHandler(stderr_handler) - # ========== Main Program ========== if __name__ == "__main__": + args = parse_cmdline_arguments() + + stdout_handler, stderr_handler = rbackup.logging.retrieve_console_handlers( + debug=args.debug + ) + syslog.addHandler(stdout_handler) + syslog.addHandler(stderr_handler) + with daemon.DaemonContext(): pass