2
0
Fork 0

chore: add custom logging config

This commit is contained in:
Luca 2024-05-12 22:08:41 +02:00
parent 10dbb06957
commit 69c9faa4bc
2 changed files with 22 additions and 1 deletions

View File

@ -41,7 +41,8 @@ class WebhookReceiver(BaseReceiver):
if not sender: if not sender:
raise ValueError("message has no sender") raise ValueError("message has no sender")
logging.getLogger("django.server").info( logger.info(
f"received sms via webhook\nkey: {key}\nfrom: {sender}\nadditional fields: {pformat(kwargs)}\n\n{text}" f"received sms via webhook\nkey: {key}\nfrom: {sender}\nadditional fields: {pformat(kwargs)}\n\n{text}"
) )
yield Message(key, sender=sender, text=text, type=MessageType.INBOUND) yield Message(key, sender=sender, text=text, type=MessageType.INBOUND)

View File

@ -240,3 +240,23 @@ SMS_OUTBOUND_BACKEND = ".".join(
) )
SMS_SETTINGS = env.dict("SMS_SETTINGS", default={}) SMS_SETTINGS = env.dict("SMS_SETTINGS", default={})
SMS_WEBHOOK_SECRET = env("SMS_WEBHOOK_SECRET", default=None) SMS_WEBHOOK_SECRET = env("SMS_WEBHOOK_SECRET", default=None)
# Logging
# https://docs.djangoproject.com/en/5.0/howto/logging/#customize-logging-configuration
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"level": "DEBUG" if DEBUG else "WARNING",
"class": "logging.StreamHandler",
},
},
"loggers": {
"shiftregister": {
"level": "DEBUG" if DEBUG else "WARNING",
"handlers": ["console"],
},
},
}