Skip to content

Commit

Permalink
[support] Supported slack notify.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Jun 4, 2024
1 parent e4752dd commit 253d18d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
36 changes: 36 additions & 0 deletions jpnic_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,42 @@
}
}

# Logging
LOGGING = {
"version": 1,
"filters": {
"require_debug_true": {
"()": "django.utils.log.RequireDebugTrue",
},
"require_debug_false": {
"()": "django.utils.log.RequireDebugFalse",
},
},
"handlers": {
"slack_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django_slack.log.SlackExceptionHandler",
'template': os.path.join(BASE_DIR, 'jpnic_admin/templates/slack/message.slack')
},
},
"loggers": {
"django": {
"handlers": ["slack_admins"],
"propagate": True,
"level": "INFO",
},
"": {
"handlers": ["slack_admins"],
"level": "DEBUG",
},
},
}

SLACK_ENDPOINT_URL = (
os.getenv("SLACK_ENDPOINT_URL", "")
)

# Debug
if DEBUG:
import socket
Expand Down
6 changes: 6 additions & 0 deletions jpnic_admin/templates/slack/message.slack
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends django_slack %}
{% load django_slack %}
{% block text %}
{% if is_channel %}<!channel>{% endif %}
{{ text }}
{% endblock %}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Django==5.0.6
django-configurations==2.5.1
django-debug-toolbar==4.4.2
django-mathfilters==1.0.0
django-slack==5.19.0
django-tidb==5.0.0
django-widget-tweaks==1.5.0
djangorestframework==3.15.1
Expand Down

0 comments on commit 253d18d

Please sign in to comment.