Change verbose option to granular verbosity

Pegleg's current verbose option simply sets the logging level to either
DEBUG or ERROR. This change allows users to enter a specific logging
level anywhere between DEBUG and CRITICAL. The default logging level is
set to 40=ERROR.

The original verbose option will be kept in order to preserve backwards
compatibility on existing scripts.

Change-Id: I2cb81c55ab070380c4336ab8d75a9bf1c18b95fc
This commit is contained in:
Ian H. Pittwood 2019-09-24 09:06:48 -05:00
parent 14f8600e37
commit 5ef28bf804
1 changed files with 17 additions and 6 deletions

View File

@ -132,19 +132,30 @@ SITE_REPOSITORY_ARGUMENT = click.argument(
is_flag=True,
default=False,
help='Enable debug logging')
def main(*, verbose):
@click.option(
'-l',
'--logging-level',
'logging_level',
default='40',
show_default=True,
type=click.Choice(['10', '20', '30', '40', '50']),
help='Sets logging level where:\n'
'10=DEBUG\n'
'20=INFO\n'
'30=WARNING\n'
'40=ERROR\n'
'50=CRITICAL')
def main(*, verbose, logging_level):
"""Main CLI meta-group, which includes the following groups:
* site: site-level actions
* repo: repository-level actions
"""
lvl = logging_level
if verbose:
log_level = logging.DEBUG
else:
log_level = logging.ERROR
logging.basicConfig(format=LOG_FORMAT, level=log_level)
lvl = logging.DEBUG
logging.basicConfig(format=LOG_FORMAT, level=int(lvl))
@main.group(help='Commands related to repositories')