Set log level by argv.

This commit is contained in:
voussoir 2020-11-20 16:23:36 -08:00
parent a81af363ff
commit 8de342b054

View file

@ -17,6 +17,7 @@ import gevent.pywsgi
import sys import sys
from voussoirkit import pathclass from voussoirkit import pathclass
from voussoirkit import vlogging
import bot import bot
import ycdl import ycdl
@ -28,6 +29,7 @@ import backend
site = backend.site site = backend.site
HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https') HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https')
LOG_LEVEL = vlogging.NOTSET
def ycdl_flask_launch( def ycdl_flask_launch(
*, *,
@ -57,8 +59,8 @@ def ycdl_flask_launch(
site.localhost_only = True site.localhost_only = True
youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key()) youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key())
backend.common.init_ycdldb(youtube_core, create=create, log_level=logging.DEBUG) backend.common.init_ycdldb(youtube_core, create=create, log_level=LOG_LEVEL)
ycdl.ytrss.log.setLevel(logging.DEBUG) ycdl.ytrss.log.setLevel(LOG_LEVEL)
if refresh_rate is not None: if refresh_rate is not None:
backend.common.start_refresher_thread(refresh_rate) backend.common.start_refresher_thread(refresh_rate)
@ -83,6 +85,9 @@ def ycdl_flask_launch_argparse(args):
) )
def main(argv): def main(argv):
global LOG_LEVEL
(LOG_LEVEL, argv) = vlogging.get_level_by_argv(argv)
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('port', nargs='?', type=int, default=5000) parser.add_argument('port', nargs='?', type=int, default=5000)