Skip to content

Commit

Permalink
532: moves the logger warning to the initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Troussard committed Mar 23, 2024
1 parent 103d28c commit 313fe40
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions requests_oauthlib/log_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def __init__(self):
environment variable.
"""
super().__init__()
self.mode = os.getenv('DEBUG_MODE_TOKEN_FILTER', 'DEFAULT').upper()
self.mode = os.getenv('DEBUG_MODE_TOKEN_FILTER', 'DEFAULT').upper()
if self.mode == 'DEFAULT':
msg = "Your logger, when in DEBUG mode, will log TOKENS"
raise Warning(msg)

def filter(self, record):
"""
Expand All @@ -37,7 +40,4 @@ def filter(self, record):
record.msg = re.sub(r'Bearer (\w+)', '[MASKED]', record.getMessage())
elif self.mode == "SUPPRESS":
return False
elif self.mode == "DEFAULT":
msg = "Your logger, when in DEBUG mode, will log TOKENS"
raise Warning(msg)
return True
return True # if mode is not MASKED then DEFAULT is implied

0 comments on commit 313fe40

Please sign in to comment.