Always use the same logging format

This helps differentiate errors, warnings and regular messages.
This commit is contained in:
Daniel Martí 2015-10-05 21:43:08 +02:00
parent 48645072ee
commit 73f9c1d1c2
1 changed files with 7 additions and 4 deletions

11
fdroid
View File

@ -99,12 +99,15 @@ def main():
verbose = any(s in sys.argv for s in ['-v', '--verbose'])
quiet = any(s in sys.argv for s in ['-q', '--quiet'])
# Helpful to differentiate warnings from errors even when on quiet
logformat = '%(levelname)s: %(message)s'
loglevel = logging.INFO
if verbose:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
loglevel = logging.DEBUG
elif quiet:
logging.basicConfig(format='%(message)s', level=logging.WARN)
else:
logging.basicConfig(format='%(message)s', level=logging.INFO)
loglevel = logging.WARN
logging.basicConfig(format=logformat, level=loglevel)
if verbose and quiet:
logging.critical("Specifying --verbose and --quiet and the same time is silly")