Make use of rbackup.logging
This commit is contained in:
parent
38683a1318
commit
c4476693c8
23
bin/backupd
23
bin/backupd
@ -14,8 +14,10 @@ by the backup script and
|
|||||||
TODO inspect python-daemon for use with this script
|
TODO inspect python-daemon for use with this script
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import daemon
|
import daemon
|
||||||
import logging
|
import logging
|
||||||
|
import rbackup.logging
|
||||||
|
|
||||||
from rbackup.struct.repository import Repository
|
from rbackup.struct.repository import Repository
|
||||||
|
|
||||||
@ -36,24 +38,19 @@ def parse_cmdline_arguments(**kwargs):
|
|||||||
|
|
||||||
|
|
||||||
# ========== Logging Setup ==========
|
# ========== Logging Setup ==========
|
||||||
console_formatter = logging.Formatter(LOGFORMAT)
|
|
||||||
syslog = logging.getLogger("rbackup")
|
syslog = logging.getLogger("rbackup")
|
||||||
syslog.setLevel(logging.DEBUG)
|
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 ==========
|
# ========== Main Program ==========
|
||||||
if __name__ == "__main__":
|
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():
|
with daemon.DaemonContext():
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user