41 general = optparse.OptionGroup(parser, "General Options") |
41 general = optparse.OptionGroup(parser, "General Options") |
42 |
42 |
43 general.add_option('-q', '--quiet', dest='loglevel', action='store_const', const=logging.WARNING, help="Less output") |
43 general.add_option('-q', '--quiet', dest='loglevel', action='store_const', const=logging.WARNING, help="Less output") |
44 general.add_option('-v', '--verbose', dest='loglevel', action='store_const', const=logging.INFO, help="More output") |
44 general.add_option('-v', '--verbose', dest='loglevel', action='store_const', const=logging.INFO, help="More output") |
45 general.add_option('-D', '--debug', dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output") |
45 general.add_option('-D', '--debug', dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output") |
|
46 general.add_option('--debug-for', action='append', metavar='MODULE', help="Enable logging for the given logger/module name") |
46 |
47 |
47 parser.add_option_group(general) |
48 parser.add_option_group(general) |
48 |
49 |
49 # |
50 # |
50 parser.add_option('-c', '--command', metavar='CMD', default=os.environ.get('SSH_ORIGINAL_COMMAND'), |
51 parser.add_option('-c', '--command', metavar='CMD', default=os.environ.get('SSH_ORIGINAL_COMMAND'), |
59 parser.add_option('-P', '--restrict-path', metavar='PATH', default=False, |
60 parser.add_option('-P', '--restrict-path', metavar='PATH', default=False, |
60 help="restrict to given path prefix") |
61 help="restrict to given path prefix") |
61 |
62 |
62 # defaults |
63 # defaults |
63 parser.set_defaults( |
64 parser.set_defaults( |
|
65 debug_for = [], |
64 loglevel = logging.WARNING, |
66 loglevel = logging.WARNING, |
65 ) |
67 ) |
66 |
68 |
67 # parse |
69 # parse |
68 options, args = parser.parse_args(argv[1:]) |
70 options, args = parser.parse_args(argv[1:]) |
70 # configure |
72 # configure |
71 logging.basicConfig( |
73 logging.basicConfig( |
72 format = '%(levelname)6s %(name)s : %(funcName)s : %(message)s', |
74 format = '%(levelname)6s %(name)s : %(funcName)s : %(message)s', |
73 level = options.loglevel, |
75 level = options.loglevel, |
74 ) |
76 ) |
|
77 |
|
78 # enable debugging for specific targets |
|
79 for target in options.debug_for : |
|
80 logging.getLogger(target).setLevel(logging.DEBUG) |
75 |
81 |
76 return options, args |
82 return options, args |
77 |
83 |
78 def rsync_wrapper (command, restrict='lvm:') : |
84 def rsync_wrapper (command, restrict='lvm:') : |
79 """ |
85 """ |