# Path: feedhq/logging.py
# def configure_logging(debug=False, syslog=False, silenced_loggers=None,
#                       level_overrides=None):
#     if silenced_loggers is None:
#         silenced_loggers = []
#     if level_overrides is None:
#         level_overrides = {}
#     level = 'DEBUG' if debug else 'INFO'
#     renderers = [
#         dev.ConsoleRenderer(),
#     ] if debug else [
#         logstash_processor,
#         processors.JSONRenderer(separators=(',', ':')),
#         add_syslog_program(syslog),
#     ]
#     structlog_processors = [
#         stdlib.filter_by_level,
#         stdlib.add_logger_name,
#         stdlib.add_log_level,
#         fix_logger_name,
#         format_request,
#         ensure_event,
#         stdlib.PositionalArgumentsFormatter(),
#         processors.TimeStamper(fmt="ISO", key='@timestamp'),
#         processors.StackInfoRenderer(),
#         processors.format_exc_info,
#     ] + renderers
# 
#     configure(
#         processors=structlog_processors,
#         context_class=dict,
#         logger_factory=stdlib.LoggerFactory(),
#         wrapper_class=stdlib.BoundLogger,
#         cache_logger_on_first_use=True,
#     )
# 
#     structlog = {'handlers': ['raw'],
#                  'level': level,
#                  'propagate': False}
#     null = {'handlers': ['null'],
#             'propagate': False}
#     loggers = {l: root(level_overrides.get(l, level))
#                for l, _, _ in logging_tree.tree()[2]}
#     loggers['feedhq'] = structlog
# 
#     for nulled_logger in silenced_loggers:
#         loggers[nulled_logger] = null
# 
#     raw = {
#         'level': level,
#         'class': 'logging.handlers.SysLogHandler',
#         'address': '/dev/log',
#         'facility': 'local0',
#     } if syslog else {
#         'level': level,
#         'class': 'logging.StreamHandler',
#     }
# 
#     return {
#         'version': 1,
#         'level': level,
#         'handlers': {
#             'root': {
#                 'level': level,
#                 '()': StructlogHandler,
#             },
#             'raw': raw,
#             'null': {
#                 'class': 'logging.NullHandler',
#             },
#         },
#         'loggers': loggers,
#         'root': root(level),
#     }
# 
# Path: feedhq/profiles/forms.py
# class AuthForm(AuthenticationForm):
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.fields['username'].label = _('Username or Email')


import logging.config
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from ratelimitbackend import admin
from ratelimitbackend.views import login
from . import monkey
from . import views  # noqa
from .logging import configure_logging  # noqa
from .profiles.forms import AuthForm  # noqa


monkey.patch_html5lib()
monkey.patch_feedparser()


admin.autodiscover()

urlpatterns = [
    url(r'^admin/rq/', include('django_rq_dashboard.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'^subscriber/', include('django_push.subscriber.urls')),
    url(r'^health/$', views.health, name='health'),
    url(r'^robots.txt$', views.robots),
    url(r'^humans.txt$', views.humans),
    url(r'^favicon.ico$', views.favicon),
    url(r'^apple-touch-icon-precomposed.png$', views.touch_icon),
    url(r'^apple-touch-icon.png$', views.touch_icon),
    url(r'^', include(('feedhq.reader.urls', 'reader'), namespace='reader')),
    url(r'^accounts/', include('feedhq.profiles.urls')),
    url(r'^', include(('feedhq.feeds.urls', 'feeds'), namespace='feeds')),
    url(r'^login/$', login, {'authentication_form': AuthForm}, name='login'),
    url(r'^logout/$', views.logout, name='logout'),
]

urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# We need logging to be configured late -- in the settings it's too soon for
# logging_tree to properly detect loggers.

# Path: feedhq/logging.py
# def configure_logging(debug=False, syslog=False, silenced_loggers=None,
#                       level_overrides=None):
#     if silenced_loggers is None:
#         silenced_loggers = []
#     if level_overrides is None:
#         level_overrides = {}
#     level = 'DEBUG' if debug else 'INFO'
#     renderers = [
#         dev.ConsoleRenderer(),
#     ] if debug else [
#         logstash_processor,
#         processors.JSONRenderer(separators=(',', ':')),
#         add_syslog_program(syslog),
#     ]
#     structlog_processors = [
#         stdlib.filter_by_level,
#         stdlib.add_logger_name,
#         stdlib.add_log_level,
#         fix_logger_name,
#         format_request,
#         ensure_event,
#         stdlib.PositionalArgumentsFormatter(),
#         processors.TimeStamper(fmt="ISO", key='@timestamp'),
#         processors.StackInfoRenderer(),
#         processors.format_exc_info,
#     ] + renderers
# 
#     configure(
#         processors=structlog_processors,
#         context_class=dict,
#         logger_factory=stdlib.LoggerFactory(),
#         wrapper_class=stdlib.BoundLogger,
#         cache_logger_on_first_use=True,
#     )
# 
#     structlog = {'handlers': ['raw'],
#                  'level': level,
#                  'propagate': False}
#     null = {'handlers': ['null'],
#             'propagate': False}
#     loggers = {l: root(level_overrides.get(l, level))
#                for l, _, _ in logging_tree.tree()[2]}
#     loggers['feedhq'] = structlog
# 
#     for nulled_logger in silenced_loggers:
#         loggers[nulled_logger] = null
# 
#     raw = {
#         'level': level,
#         'class': 'logging.handlers.SysLogHandler',
#         'address': '/dev/log',
#         'facility': 'local0',
#     } if syslog else {
#         'level': level,
#         'class': 'logging.StreamHandler',
#     }
# 
#     return {
#         'version': 1,
#         'level': level,
#         'handlers': {
#             'root': {
#                 'level': level,
#                 '()': StructlogHandler,
#             },
#             'raw': raw,
#             'null': {
#                 'class': 'logging.NullHandler',
#             },
#         },
#         'loggers': loggers,
#         'root': root(level),
#     }
# 
# Path: feedhq/profiles/forms.py
# class AuthForm(AuthenticationForm):
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.fields['username'].label = _('Username or Email')


# Path: feedhq/urls.py
import logging.config
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from ratelimitbackend import admin
from ratelimitbackend.views import login
from . import monkey
from . import views  # noqa
from .logging import configure_logging  # noqa
from .profiles.forms import AuthForm  # noqa



monkey.patch_html5lib()
monkey.patch_feedparser()


admin.autodiscover()

urlpatterns = [
    url(r'^admin/rq/', include('django_rq_dashboard.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'^subscriber/', include('django_push.subscriber.urls')),
    url(r'^health/$', views.health, name='health'),
    url(r'^robots.txt$', views.robots),
    url(r'^humans.txt$', views.humans),
    url(r'^favicon.ico$', views.favicon),
    url(r'^apple-touch-icon-precomposed.png$', views.touch_icon),
    url(r'^apple-touch-icon.png$', views.touch_icon),
    url(r'^', include(('feedhq.reader.urls', 'reader'), namespace='reader')),
    url(r'^accounts/', include('feedhq.profiles.urls')),
    url(r'^', include(('feedhq.feeds.urls', 'feeds'), namespace='feeds')),
    url(r'^login/$', login, {'authentication_form': AuthForm}, name='login'),
    url(r'^logout/$', views.logout, name='logout'),
]

urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# We need logging to be configured late -- in the settings it's too soon for
# logging_tree to properly detect loggers.

logging.config.dictConfig(configure_logging(