Move logging basicconfig effort to frontmost application layer.

This commit is contained in:
voussoir 2020-08-12 11:17:10 -07:00
parent ee89582a1b
commit 3f3eda58b1
6 changed files with 11 additions and 22 deletions

View file

@ -2,9 +2,6 @@
Do not execute this file directly. Do not execute this file directly.
Use ycdl_launch.py to start the server with gevent. Use ycdl_launch.py to start the server with gevent.
''' '''
import logging
logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR)
import flask; from flask import request import flask; from flask import request
import mimetypes import mimetypes
import os import os

View file

@ -1,5 +1,8 @@
import logging import logging
logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR) logging.basicConfig()
logging.getLogger('ycdl.ycdldb').setLevel(logging.DEBUG)
logging.getLogger('ycdl.ytapi').setLevel(logging.DEBUG)
logging.getLogger('ycdl.ytrss').setLevel(logging.DEBUG)
import gevent.monkey import gevent.monkey
gevent.monkey.patch_all() gevent.monkey.patch_all()

View file

@ -2,6 +2,11 @@
Run `python -i ycdl_repl.py to get an interpreter Run `python -i ycdl_repl.py to get an interpreter
session with these variables preloaded. session with these variables preloaded.
''' '''
import logging
logging.basicConfig()
logging.getLogger('ycdl.ycdldb').setLevel(logging.DEBUG)
logging.getLogger('ycdl.ytapi').setLevel(logging.DEBUG)
logging.getLogger('ycdl.ytrss').setLevel(logging.DEBUG)
import bot import bot
import ycdl import ycdl

View file

@ -1,6 +1,3 @@
import logging
logging.basicConfig(level=logging.WARNING)
import bot3 as bot import bot3 as bot
import os import os
import traceback import traceback

View file

@ -15,12 +15,6 @@ from voussoirkit import pathclass
from voussoirkit import sqlhelpers from voussoirkit import sqlhelpers
logging.basicConfig()
logging.getLogger('googleapiclient.discovery').setLevel(logging.WARNING)
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING)
logging.getLogger('requests.packages.urllib3.util.retry').setLevel(logging.WARNING)
class YCDLDBCacheManagerMixin: class YCDLDBCacheManagerMixin:
_THING_CLASSES = { _THING_CLASSES = {
'channel': 'channel':
@ -417,7 +411,6 @@ class YCDLDB(
# LOGGING # LOGGING
self.log = logging.getLogger(__name__) self.log = logging.getLogger(__name__)
self.log.setLevel(logging.DEBUG)
# DATABASE # DATABASE
self.database_filepath = self.data_directory.with_child(constants.DEFAULT_DBNAME) self.database_filepath = self.data_directory.with_child(constants.DEFAULT_DBNAME)

View file

@ -4,12 +4,6 @@ import logging
from . import helpers from . import helpers
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
logging.getLogger('googleapiclient.discovery').setLevel(logging.WARNING)
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING)
logging.getLogger('requests.packages.urllib3.util.retry').setLevel(logging.WARNING)
def int_none(x): def int_none(x):
if x is None: if x is None:
@ -52,7 +46,6 @@ class Video:
def __str__(self): def __str__(self):
return 'Video:%s' % self.id return 'Video:%s' % self.id
class Youtube: class Youtube:
def __init__(self, key): def __init__(self, key):
youtube = apiclient.discovery.build( youtube = apiclient.discovery.build(
@ -60,6 +53,7 @@ class Youtube:
serviceName='youtube', serviceName='youtube',
version='v3', version='v3',
) )
self.log = logging.getLogger(__name__)
self.youtube = youtube self.youtube = youtube
def get_playlist_videos(self, playlist_id): def get_playlist_videos(self, playlist_id):
@ -76,7 +70,7 @@ class Youtube:
videos = self.get_video(video_ids) videos = self.get_video(video_ids)
videos.sort(key=lambda x: x.published, reverse=True) videos.sort(key=lambda x: x.published, reverse=True)
log.debug('Got %d more videos.', len(videos)) self.log.debug('Got %d more videos.', len(videos))
for video in videos: for video in videos:
yield video yield video