def verbose(f):
@click.pass_context<EOL>def new_func(ctx, *args, **kwargs):<EOL><INDENT>global log<EOL>verbosity = ["<STR_LIT>", "<STR_LIT:error>", "<STR_LIT>", "<STR_LIT:info>", "<STR_LIT>"][<EOL>int(min(ctx.obj.get("<STR_LIT>", <NUM_LIT:0>), <NUM_LIT:4>))<EOL>]<EOL>log.setLevel(getattr(logging, verbosity.upper()))<EOL>formatter = logging.Formatter(<EOL>"<STR_LIT>"<EOL>)<EOL>ch = logging.StreamHandler()<EOL>ch.setLevel(getattr(logging, verbosity.upper()))<EOL>ch.setFormatter(formatter)<EOL>log.addHandler(ch)<EOL>if ctx.obj.get("<STR_LIT>", <NUM_LIT:0>) > <NUM_LIT:4>:<EOL><INDENT>verbosity = ["<STR_LIT>", "<STR_LIT:error>", "<STR_LIT>", "<STR_LIT:info>", "<STR_LIT>"][<EOL>int(min(ctx.obj.get("<STR_LIT>", <NUM_LIT:4>) - <NUM_LIT:4>, <NUM_LIT:4>))<EOL>]<EOL>log = logging.getLogger("<STR_LIT>")<EOL>log.setLevel(getattr(logging, verbosity.upper()))<EOL>log.addHandler(ch)<EOL><DEDENT>if ctx.obj.get("<STR_LIT>", <NUM_LIT:0>) > <NUM_LIT:8>:<EOL><INDENT>verbosity = ["<STR_LIT>", "<STR_LIT:error>", "<STR_LIT>", "<STR_LIT:info>", "<STR_LIT>"][<EOL>int(min(ctx.obj.get("<STR_LIT>", <NUM_LIT:8>) - <NUM_LIT:8>, <NUM_LIT:4>))<EOL>]<EOL>log = logging.getLogger("<STR_LIT>")<EOL>log.setLevel(getattr(logging, verbosity.upper()))<EOL>log.addHandler(ch)<EOL><DEDENT>return ctx.invoke(f, *args, **kwargs)<EOL><DEDENT>return update_wrapper(new_func, f)<EOL>
Add verbose flags and add logging handlers