From f052858d5fd4d5f4c7b1fb01eb3ae0d9a4c9bcf4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 26 Nov 2017 02:37:11 -0800 Subject: [PATCH] Improve log creation and use custom formatter. --- etiquette/photodb.py | 6 +++--- frontends/etiquette_flask/etiquette_flask_launch.py | 6 ++++++ frontends/etiquette_repl.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 64acb42..610dbf1 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -23,8 +23,7 @@ from voussoirkit import pathclass from voussoirkit import spinal -logging.basicConfig(level=logging.DEBUG) -logging.getLogger('PIL.PngImagePlugin').setLevel(logging.WARNING) +logging.basicConfig() # Note: Setting user_version pragma in init sequence is safe because it only @@ -1160,8 +1159,9 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs os.makedirs(self.thumbnail_directory.absolute_path, exist_ok=True) # OTHER - self.log = logging.getLogger(__name__) + self.log = logging.getLogger('etiquette:%s' % self.data_directory.absolute_path) self.log.setLevel(self.config['log_level']) + self.on_commit_queue = [] self._cached_frozen_children = None diff --git a/frontends/etiquette_flask/etiquette_flask_launch.py b/frontends/etiquette_flask/etiquette_flask_launch.py index 8b5e109..f673a74 100644 --- a/frontends/etiquette_flask/etiquette_flask_launch.py +++ b/frontends/etiquette_flask/etiquette_flask_launch.py @@ -1,6 +1,12 @@ import gevent.monkey gevent.monkey.patch_all() +import logging +handler = logging.StreamHandler() +log_format = '{levelname}:etiquette.{module}.{funcName}: {message}' +handler.setFormatter(logging.Formatter(log_format, style='{')) +logging.getLogger().addHandler(handler) + import etiquette_flask import gevent.pywsgi import gevent.wsgi diff --git a/frontends/etiquette_repl.py b/frontends/etiquette_repl.py index ee60810..c9d238c 100644 --- a/frontends/etiquette_repl.py +++ b/frontends/etiquette_repl.py @@ -1,6 +1,12 @@ # Use with # py -i etiquette_easy.py +import logging +handler = logging.StreamHandler() +log_format = '{levelname}:etiquette.{module}.{funcName}: {message}' +handler.setFormatter(logging.Formatter(log_format, style='{')) +logging.getLogger().addHandler(handler) + import argparse import os import sys