Skip to content

Commit

Permalink
error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ialbert committed Mar 31, 2021
1 parent 81f55d6 commit 315a08a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion biostar/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ def tags_list(request):
@check_params(allowed=ALLOWED_PARAMS)
def community_list(request):
users = User.objects.select_related("profile")

page = request.GET.get("page", 1)
ordering = request.GET.get("order", "visit")
limit_to = request.GET.get("limit", "time")
Expand Down
18 changes: 13 additions & 5 deletions biostar/logconf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from django.core.cache import cache
from django.core.servers import basehttp

#
# To see all log messages: export DJANGO_LOG_LEVEL=DEBUG
#
Expand All @@ -21,11 +22,10 @@ class RateLimitFilter(object):
Limits the number of error emails when errors get triggered.
"""
# Time out in seconds.
TIMEOUT = 600
TIMEOUT = 60
CACHE_KEY = "error-limiter"

def filter(self, record):

exists = cache.get(self.CACHE_KEY)
if not exists:
cache.set(self.CACHE_KEY, 1, self.TIMEOUT)
Expand Down Expand Up @@ -62,6 +62,7 @@ def filter(self, record):
},

'handlers': {

'console': {
'class': 'logging.StreamHandler',
'formatter': 'verbose'
Expand All @@ -72,20 +73,27 @@ def filter(self, record):
'filters': ['require_debug_false', 'rate_limit'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},

'errors': {
'level': 'ERROR',
'filters': ['rate_limit'],
'class': 'logging.FileHandler',
'filename': 'error.log',
}

},

'loggers': {

'django': {
'handlers': ['console', 'mail_admins'],
'handlers': ['console', 'mail_admins', 'errors'],
'level': DJANGO_LOG_LEVEL,

},

'engine': {
'handlers': ['console', 'mail_admins'],
'handlers': ['console', 'mail_admins', 'errors'],
'level': LOG_LEVEL,
},

Expand Down

0 comments on commit 315a08a

Please sign in to comment.