root: use filtering_bound_logger for speed improvements
This commit is contained in:
parent
3c4ff65a01
commit
3d112e7688
|
@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from json import dumps
|
from json import dumps
|
||||||
|
@ -336,7 +337,7 @@ if not DEBUG and _ERROR_REPORTING:
|
||||||
RedisIntegration(),
|
RedisIntegration(),
|
||||||
],
|
],
|
||||||
before_send=before_send,
|
before_send=before_send,
|
||||||
release="authentik@%s" % __version__,
|
release=f"authentik@{__version__}",
|
||||||
traces_sample_rate=0.6,
|
traces_sample_rate=0.6,
|
||||||
environment=CONFIG.y("error_reporting.environment", "customer"),
|
environment=CONFIG.y("error_reporting.environment", "customer"),
|
||||||
send_default_pii=CONFIG.y_bool("error_reporting.send_pii", False),
|
send_default_pii=CONFIG.y_bool("error_reporting.send_pii", False),
|
||||||
|
@ -353,23 +354,28 @@ if not DEBUG and _ERROR_REPORTING:
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
MEDIA_URL = "/media/"
|
MEDIA_URL = "/media/"
|
||||||
|
|
||||||
|
LOG_LEVEL = CONFIG.y("log_level").upper()
|
||||||
|
|
||||||
|
|
||||||
structlog.configure_once(
|
structlog.configure_once(
|
||||||
processors=[
|
processors=[
|
||||||
structlog.stdlib.add_log_level,
|
structlog.stdlib.add_log_level,
|
||||||
structlog.stdlib.add_logger_name,
|
structlog.stdlib.add_logger_name,
|
||||||
|
structlog.threadlocal.merge_threadlocal_context,
|
||||||
add_process_id,
|
add_process_id,
|
||||||
add_common_fields(CONFIG.y("error_reporting.environment", "customer")),
|
add_common_fields(CONFIG.y("error_reporting.environment", "customer")),
|
||||||
structlog_add_request_id,
|
structlog_add_request_id,
|
||||||
structlog.stdlib.PositionalArgumentsFormatter(),
|
structlog.stdlib.PositionalArgumentsFormatter(),
|
||||||
structlog.processors.TimeStamper(),
|
structlog.processors.TimeStamper(fmt="iso", utc=False),
|
||||||
structlog.processors.StackInfoRenderer(),
|
structlog.processors.StackInfoRenderer(),
|
||||||
structlog.processors.format_exc_info,
|
structlog.processors.format_exc_info,
|
||||||
structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
|
structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
|
||||||
],
|
],
|
||||||
context_class=structlog.threadlocal.wrap_dict(dict),
|
context_class=structlog.threadlocal.wrap_dict(dict),
|
||||||
logger_factory=structlog.stdlib.LoggerFactory(),
|
logger_factory=structlog.stdlib.LoggerFactory(),
|
||||||
wrapper_class=structlog.stdlib.BoundLogger,
|
wrapper_class=structlog.make_filtering_bound_logger(
|
||||||
|
getattr(logging, LOG_LEVEL, logging.WARNING)
|
||||||
|
),
|
||||||
cache_logger_on_first_use=True,
|
cache_logger_on_first_use=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -410,8 +416,6 @@ LOGGING = {
|
||||||
|
|
||||||
TEST = False
|
TEST = False
|
||||||
TEST_RUNNER = "authentik.root.test_runner.PytestTestRunner"
|
TEST_RUNNER = "authentik.root.test_runner.PytestTestRunner"
|
||||||
LOG_LEVEL = CONFIG.y("log_level").upper()
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGING_HANDLER_MAP = {
|
_LOGGING_HANDLER_MAP = {
|
||||||
"": LOG_LEVEL,
|
"": LOG_LEVEL,
|
||||||
|
|
Reference in New Issue