Don't use log_level from config -- pass it in to constructor.

The problem with the log_level config was twofold. First, there is some
work to be done before the config is be loaded, and so we must hardcode
the log level for that. I was using debug. Secondly, I have realized
that log levels should be pushed as close to the front of the UI code
as possible, not the backend code.
This commit is contained in:
voussoir 2020-11-08 20:09:16 -08:00
parent 12ee2adedf
commit de2f1caa42
2 changed files with 4 additions and 8 deletions

View file

@ -253,8 +253,6 @@ DEFAULT_CONFIGNAME = 'config.json'
DEFAULT_THUMBDIR = 'site_thumbnails' DEFAULT_THUMBDIR = 'site_thumbnails'
DEFAULT_CONFIGURATION = { DEFAULT_CONFIGURATION = {
'log_level': logging.DEBUG,
'cache_size': { 'cache_size': {
'album': 1000, 'album': 1000,
'bookmark': 100, 'bookmark': 100,

View file

@ -15,6 +15,7 @@ from voussoirkit import pathclass
from voussoirkit import ratelimiter from voussoirkit import ratelimiter
from voussoirkit import spinal from voussoirkit import spinal
from voussoirkit import sqlhelpers from voussoirkit import sqlhelpers
from voussoirkit import vlogging
from . import constants from . import constants
from . import decorators from . import decorators
@ -1711,6 +1712,7 @@ class PhotoDB(
*, *,
create=True, create=True,
ephemeral=False, ephemeral=False,
log_level=vlogging.NOTSET,
skip_version_check=False, skip_version_check=False,
): ):
''' '''
@ -1759,8 +1761,8 @@ class PhotoDB(
raise exceptions.BadDataDirectory(self.data_directory.absolute_path) raise exceptions.BadDataDirectory(self.data_directory.absolute_path)
# LOGGING # LOGGING
self.log = logging.getLogger('etiquette:%s' % self.data_directory.absolute_path) self.log = vlogging.getLogger('etiquette:%s' % self.data_directory.absolute_path)
self.log.setLevel(logging.DEBUG) self.log.setLevel(log_level)
# DATABASE # DATABASE
if self.ephemeral: if self.ephemeral:
@ -1791,10 +1793,6 @@ class PhotoDB(
# CONFIG # CONFIG
self.config_filepath = self.data_directory.with_child(constants.DEFAULT_CONFIGNAME) self.config_filepath = self.data_directory.with_child(constants.DEFAULT_CONFIGNAME)
self.load_config() self.load_config()
if self.config['log_level'] is None:
self.log.setLevel(logging.NOTSET)
else:
self.log.setLevel(self.config['log_level'])
self.caches = { self.caches = {
'album': cacheclass.Cache(maxlen=self.config['cache_size']['album']), 'album': cacheclass.Cache(maxlen=self.config['cache_size']['album']),