Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Remove debug logging from has_active_block #1296

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

### Changed

- Remove Sample Data and Update Registration Text [#1291](https://github.com/open-apparel-registry/open-apparel-registry/pull/1291)

### Deprecated

### Removed

- Remove debug logging from has_active_block [#1296](https://github.com/open-apparel-registry/open-apparel-registry/pull/1296)

### Fixed

- Adjust settings so fast refresh works in development [#1284](https://github.com/open-apparel-registry/open-apparel-registry/pull/1284)
Expand Down
31 changes: 0 additions & 31 deletions src/django/api/middleware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import datetime
import logging
import json

from django.utils import timezone
Expand All @@ -15,8 +14,6 @@
from api.models import RequestLog
from api.limits import get_api_block

logger = logging.getLogger(__name__)


def _report_error_to_rollbar(request, auth):
ROLLBAR = getattr(settings, 'ROLLBAR', {})
Expand Down Expand Up @@ -73,46 +70,18 @@ def get_token(request):


def has_active_block(request):
def debug_log(msg):
if request.path != '/health-check/':
logger.debug(msg)
debug_log('has_active_block handling request {0}'.format(
request.__dict__))
try:
token = get_token(request)
if token is None:
debug_log('has_active_block did not find a token')
return False
debug_log(
'has_active_block fetched token {0}...'.format(
token.pk[:4]))

contributor = token.user.contributor
debug_log(
'has_active_block fetched contributor {0}'.format(
contributor.id))
apiBlock = get_api_block(contributor)
if apiBlock is not None:
debug_log(
'has_active_block fetched block {0}'.format(
apiBlock.__dict__))
else:
debug_log(
'has_active_block no block found for contributor {0}'
.format(contributor.id))

at_datetime = datetime.datetime.now(tz=timezone.utc)
debug_log(
'has_active_block at_datetime is {0}'.format(
at_datetime))
return (apiBlock is not None and
apiBlock.until > at_datetime and apiBlock.active)
debug_log('has_active_block did not see a token header')
except ObjectDoesNotExist:
debug_log('has_active_block caught ObjectDoesNotExist exception')
debug_log('has_active_block returning False from the except block')
return False
debug_log('has_active_block returning False')
return False


Expand Down
5 changes: 0 additions & 5 deletions src/django/oar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,6 @@
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
'api.middleware': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False
}
},
}

Expand Down