27 lines
747 B
Python
27 lines
747 B
Python
import logging
|
|
|
|
from django.conf import settings
|
|
from structlog.typing import EventDict
|
|
|
|
from vbv_lernwelt.core.utils import safe_json_dumps
|
|
|
|
|
|
def structlog_convert_to_json_for_new_relic(
|
|
_: logging.Logger, __: str, event_dict: EventDict
|
|
) -> str:
|
|
"""
|
|
The *event_dict* is serialized to a json string, so that in New Relic logs
|
|
the nested keys will show up as attributes.
|
|
"""
|
|
return safe_json_dumps(event_dict)
|
|
|
|
|
|
def structlog_add_app_info(
|
|
_: logging.Logger, __: str, event_dict: EventDict
|
|
) -> EventDict:
|
|
event_dict["django_app"] = "vbv_lernwelt"
|
|
event_dict["app_environment"] = settings.APP_ENVIRONMENT
|
|
event_dict["django_app_dev_mode"] = f"vbv_lernwelt_{settings.APP_ENVIRONMENT}"
|
|
|
|
return event_dict
|