namachieli / numista-api-sdk

A Python SDK for the Numista API
MIT License
6 stars 0 forks source link

Add dynamic log filters to obfuscate sensitive data #11

Open namachieli opened 2 years ago

namachieli commented 2 years ago

This is currently being done explicitly and manually. For example:

# numista.py Numista()._api_client()
log_headers = {k: v for k, v in headers.items()}
log_headers['Numista-API-Key'] = f"***{log_headers['Numista-API-Key'][-4:]}"

if log_headers.get("Authorization", None):
    log_headers['Authorization'] = f"Bearer ***{log_headers['Authorization'][-4:]}"

This can be done dynamically by the logger More info: https://relaxdiego.com/2014/07/logging-in-python.html