1
0
Fork 0

Use voussoirkit.vlogging to take care of LOUD and setLevel.

This commit is contained in:
voussoir 2020-11-02 23:19:24 -08:00
parent 9817b4b3b4
commit 02ce43bdfe

View file

@ -10,8 +10,9 @@ from voussoirkit import betterhelp
from voussoirkit import ratelimiter from voussoirkit import ratelimiter
from voussoirkit import sqlhelpers from voussoirkit import sqlhelpers
from voussoirkit import threadpool from voussoirkit import threadpool
from voussoirkit import vlogging
log = logging.getLogger('hnarchive') log = vlogging.getLogger('hnarchive')
VERSION = 1 VERSION = 1
@ -49,10 +50,6 @@ ITEMS_COLUMNS = COLUMNS['items']
sql = sqlite3.connect('hnarchive.db') sql = sqlite3.connect('hnarchive.db')
sql.executescript(DB_INIT) sql.executescript(DB_INIT)
LOG_LOUD = 1
logging.addLevelName(LOG_LOUD, 'LOUD')
log.loud = lambda *args, **kwargs: log.log(LOG_LOUD, *args, **kwargs)
# HELPERS ########################################################################################## # HELPERS ##########################################################################################
def int_or_none(x): def int_or_none(x):
@ -378,18 +375,7 @@ def update_items_argparse(args):
commit() commit()
def main(argv): def main(argv):
logging.basicConfig() argv = vlogging.set_level_by_argv(log, argv)
if '--loud' in argv:
log.setLevel(LOG_LOUD)
argv.remove('--loud')
elif '--debug' in argv:
log.setLevel(logging.DEBUG)
argv.remove('--debug')
elif '--quiet' in argv:
log.setLevel(logging.ERROR)
argv.remove('--quiet')
else:
log.setLevel(logging.INFO)
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()