From f9129c3b936203cc82544fb09d94ccaa14db3d3c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 9 Sep 2009 13:50:12 -0400 Subject: Add logging options --- rpmbuild-remote.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'rpmbuild-remote.py') diff --git a/rpmbuild-remote.py b/rpmbuild-remote.py index 427b1b5..696a21f 100755 --- a/rpmbuild-remote.py +++ b/rpmbuild-remote.py @@ -8,8 +8,15 @@ import optparse import sys import os +LOGGING_LEVELS = { + 'debug': logging.DEBUG, + 'info': logging.INFO, + 'warning': logging.WARNING, + 'error': logging.ERROR, + 'critical': logging.CRITICAL, +} + LOG = logging.getLogger('rpmbuild-remote') -LOG.addHandler(logging.StreamHandler()) EXTENSIONS = ( '.patch', @@ -55,6 +62,15 @@ def get_parser(): action="store", type="string", dest="mock", help="Mock configuration to use (only applies to SRPM files) " "[Default: Use rpmbuild --rebuild)]") + parser.add_option("-v", "--verbose", + action="store", type="string", dest="verbose", + default="info", + help="Error level (debug|info|warning|error|critical) " + "[Default: info]") + parser.add_option("-o", "--outfile", + action="store", type="string", dest="log_file", + default=os.path.join(home, "rpmbuild-remote", "log"), + help="Log file [Default: ~/rpmbuild-remote/log]") return parser def read_section(config, section, values): @@ -187,6 +203,8 @@ def execute_jobs(opts, system, jobs): def main(): parser = get_parser() opts, args = parser.parse_args() + log_level = LOGGING_LEVELS.get(opts.verbose, logging.NOTSET) + logging.basicConfig(filename=opts.log_file, level=log_level) jobs = [] for arg in args: ext = os.path.splitext(arg)[1] -- cgit