Make log level configurable
This commit is contained in:
parent
4c0fdbe89f
commit
04b85aa280
1 changed files with 18 additions and 3 deletions
|
@ -68,10 +68,26 @@ class SearchHandler(tornado.web.RequestHandler):
|
|||
|
||||
@click.group()
|
||||
@click.option("--database", type=click.Path(dir_okay=False), required=True)
|
||||
@click.option(
|
||||
"--log-level",
|
||||
type=click.Choice(
|
||||
["debug", "info", "warn", "error"],
|
||||
case_sensitive=False,
|
||||
),
|
||||
default="warn",
|
||||
)
|
||||
@click.pass_context
|
||||
def cli(ctx, database):
|
||||
def cli(ctx, database, log_level):
|
||||
logging.basicConfig(
|
||||
level={
|
||||
"debug": logging.DEBUG,
|
||||
"info": logging.INFO,
|
||||
"warn": logging.WARN,
|
||||
"error": logging.ERROR,
|
||||
}.get(log_level.lower())
|
||||
)
|
||||
ctx.ensure_object(dict)
|
||||
ctx.obj['database'] = database
|
||||
ctx.obj["database"] = database
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
@ -97,5 +113,4 @@ def import_cards(ctx, filename):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
cli()
|
||||
|
|
Loading…
Reference in a new issue