Skip to content

Commit 313fe40

Browse files
author
Jacques Troussard
committed
532: moves the logger warning to the initializer
1 parent 103d28c commit 313fe40

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

requests_oauthlib/log_filters.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def __init__(self):
2020
environment variable.
2121
"""
2222
super().__init__()
23-
self.mode = os.getenv('DEBUG_MODE_TOKEN_FILTER', 'DEFAULT').upper()
23+
self.mode = os.getenv('DEBUG_MODE_TOKEN_FILTER', 'DEFAULT').upper()
24+
if self.mode == 'DEFAULT':
25+
msg = "Your logger, when in DEBUG mode, will log TOKENS"
26+
raise Warning(msg)
2427

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

0 commit comments

Comments
 (0)