Skip to content

Commit

Permalink
Move handler and listener default classes to class attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgilland committed Jan 23, 2015
1 parent e9ee8bb commit 7d665cf
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions flask_logconfig/__init__.py
Expand Up @@ -31,12 +31,17 @@ class LogConfig(object):
"""Flask extension for configuring Python's logging module from
application's config object.
"""
default_handler_class = FlaskQueueHandler
default_listener_class = logconfig.QueueListener

def __init__(self,
app=None,
start_listeners=True,
handler_class=FlaskQueueHandler,
listener_class=logconfig.QueueListener):
handler_class=None,
listener_class=None):
self.app = app
self.handler_class = handler_class
self.listener_class = listener_class
self.listeners = {}

if app is not None: # pragma: no cover
Expand All @@ -45,12 +50,18 @@ def __init__(self,
def init_app(self,
app,
start_listeners=True,
handler_class=FlaskQueueHandler,
listener_class=logconfig.QueueListener):
handler_class=None,
listener_class=None):
"""Initialize extension on Flask application."""
app.config.setdefault('LOGGING', None)
app.config.setdefault('LOGGING_QUEUE', [])

handler_class = (handler_class if handler_class is not None
else self.default_handler_class)

listener_class = (listener_class if listener_class is not None
else self.default_listener_class)

if app.config['LOGGING']:
# NOTE: app.logger clears all attached loggers from
# app.config['LOGGER_NAME'] but ONLY AFTER FIRST ACCESS! Therefore,
Expand Down

0 comments on commit 7d665cf

Please sign in to comment.