Skip to content

Commit

Permalink
chore: allow optional logging of Django's SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Nov 2, 2023
1 parent 305ab26 commit 9463b0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,13 @@ class SubsidyAccessPolicyCreditsAvailableResponseSerializer(SubsidyAccessPolicyR

@extend_schema_field(serializers.IntegerField)
def get_remaining_balance_per_user(self, obj):
lms_user_id = self.context.get('lms_user_id')
return obj.remaining_balance_per_user(lms_user_id=lms_user_id)
"""
The remaining balance per user for this policy, in USD cents, if applicable.
"""
if hasattr(obj, 'remaining_balance_per_user'):
lms_user_id = self.context.get('lms_user_id')
return obj.remaining_balance_per_user(lms_user_id=lms_user_id)
return None

@extend_schema_field(serializers.IntegerField)
def get_remaining_balance(self, obj):
Expand Down
14 changes: 14 additions & 0 deletions enterprise_access/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,22 @@
ENABLE_AUTO_AUTH = True

LOGGING = get_logger_config(debug=DEBUG)
LOG_SQL = False


#####################################################################
# Lastly, see if the developer has any local overrides.
if os.path.isfile(join(dirname(abspath(__file__)), 'private.py')):
from .private import * # pylint: disable=import-error

# LOG_SQL may be set to True in private.py, which will
# enable logging of SQL statements via the django.db.backends module.
if LOG_SQL:
LOGGING['loggers']['django.db.backends'] = {
'level': 'DEBUG',
'handlers': ['console'],
# We have a root 'django' logger enabled
# that we don't want to propagage too, so that
# this doesn't print multiple times.
'propagate': False,
}

0 comments on commit 9463b0d

Please sign in to comment.