|
|
@ -2,6 +2,7 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
from argparse import ArgumentParser |
|
|
|
import logging |
|
|
|
from logging.handlers import SysLogHandler |
|
|
|
import os |
|
|
|
from config import Config |
|
|
|
from watcher import Watcher |
|
|
@ -13,13 +14,18 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='%(asctime)s %(levelname)-7s %(message)s') |
|
|
|
|
|
|
|
if not os.path.exists(args.config): |
|
|
|
logging.error("Configuration file %s does not exist" % args.config) |
|
|
|
|
|
|
|
config = Config() |
|
|
|
config.read(args.config) |
|
|
|
|
|
|
|
logtarget = config.get('DEFAULT', 'logging', fallback='console') |
|
|
|
if logtarget == 'syslog': |
|
|
|
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='permwatcher: [%(levelname)s] %(message)s', \ |
|
|
|
handlers=(SysLogHandler('/dev/log', facility=SysLogHandler.LOG_DAEMON), )) |
|
|
|
else: |
|
|
|
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='%(asctime)s %(levelname)-7s %(message)s') |
|
|
|
|
|
|
|
watcher = Watcher(config) |
|
|
|
watcher.start() |