-
Couldn't load subscription status.
- Fork 10
feat: Added Log Verbosity #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Maybe it's worth checking if we can use a custom logging handler to do this logic? Maybe in the |
| httpx_logger = logging.getLogger("httpx") | ||
|
|
||
|
|
||
| class CensorSecretsFormatter(logging.Formatter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using logging.Filter instead of logging.Formatter, seems simpler IMO in this case, like so:
class SensitiveInfoFilter(logging.Filter):
def filter(self, record):
record.msg = re.sub(r'<PATTERN>', '*********', record.msg)
return True
logger.addFilter(SensitiveInfoFilter())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite what we need here, as loggingFilter filter the log so it won't be logged. I do want to log it, simply without some of the data that is being written
ai21/logger.py
Outdated
|
|
||
| def _censor_secrets(self, message: str) -> str: | ||
| # Regular expression to find the Authorization key and its value | ||
| pattern = r"('Authorization':\s*'[^']*'|'api-key':\s*'[^']*')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're logging headers, we'd need to also add to the pattern X-Amz-Security-Token as this is one of the auth headers for aws
Added support for the following methods -
set_verbose- This will more log sensitive data to your log like env variable and secretsset_debug- Another way to change log level to DEBUG