From de2f1caa421f3f2efd1292deb9a4d0cd45b4f5d5 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 8 Nov 2020 20:09:16 -0800 Subject: [PATCH] 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. --- etiquette/constants.py | 2 -- etiquette/photodb.py | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/etiquette/constants.py b/etiquette/constants.py index 39aa22e..18f6614 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -253,8 +253,6 @@ DEFAULT_CONFIGNAME = 'config.json' DEFAULT_THUMBDIR = 'site_thumbnails' DEFAULT_CONFIGURATION = { - 'log_level': logging.DEBUG, - 'cache_size': { 'album': 1000, 'bookmark': 100, diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 925cce0..2ba0f3b 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -15,6 +15,7 @@ from voussoirkit import pathclass from voussoirkit import ratelimiter from voussoirkit import spinal from voussoirkit import sqlhelpers +from voussoirkit import vlogging from . import constants from . import decorators @@ -1711,6 +1712,7 @@ class PhotoDB( *, create=True, ephemeral=False, + log_level=vlogging.NOTSET, skip_version_check=False, ): ''' @@ -1759,8 +1761,8 @@ class PhotoDB( raise exceptions.BadDataDirectory(self.data_directory.absolute_path) # LOGGING - self.log = logging.getLogger('etiquette:%s' % self.data_directory.absolute_path) - self.log.setLevel(logging.DEBUG) + self.log = vlogging.getLogger('etiquette:%s' % self.data_directory.absolute_path) + self.log.setLevel(log_level) # DATABASE if self.ephemeral: @@ -1791,10 +1793,6 @@ class PhotoDB( # CONFIG self.config_filepath = self.data_directory.with_child(constants.DEFAULT_CONFIGNAME) 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 = { 'album': cacheclass.Cache(maxlen=self.config['cache_size']['album']),