11import functools
22import glob
33import locale
4- import logging
54import sys
65from contextlib import contextmanager
76from datetime import timedelta
87from os .path import expanduser , isdir
98
109import click
10+ import click_log
1111
1212from todoman import exceptions , formatters
1313from todoman .configuration import ConfigurationException , load_config
1414from todoman .interactive import TodoEditor
1515from todoman .model import cached_property , Database , Todo
1616
1717
18+ click_log .basic_config ()
19+
20+
1821@contextmanager
1922def handle_error ():
2023 try :
@@ -194,13 +197,7 @@ def formatter(self):
194197
195198
196199@click .group (invoke_without_command = True )
197- @click .option (
198- '-v' ,
199- '--verbosity' ,
200- type = click .Choice (['CRITICAL' , 'ERROR' , 'WARNING' , 'INFO' , 'DEBUG' ]),
201- help = 'Set verbosity to the given level.' ,
202- default = 'WARNING' ,
203- )
200+ @click_log .simple_verbosity_option ()
204201@click .option ('--colour' , '--color' , default = None ,
205202 type = click .Choice (['always' , 'auto' , 'never' ]),
206203 help = ('By default todoman will disable colored output if stdout '
@@ -214,8 +211,7 @@ def formatter(self):
214211@click .pass_context
215212@click .version_option (prog_name = 'todoman' )
216213@catch_errors
217- def cli (click_ctx , color , porcelain , humanize , verbosity ):
218- logging .basicConfig (level = verbosity )
214+ def cli (click_ctx , color , porcelain , humanize ):
219215 ctx = click_ctx .ensure_object (AppContext )
220216 try :
221217 ctx .config = load_config ()
0 commit comments