A function decorator for beautiful and complete logging
Project description
Secure Logger
A Python decorator to generate redacted and nicely formatted log entries of class instantiations, class method calls and standard Python function calls. Redacts function parameter values and dict values based on a customizable list.
Redacts the following values by default:
DEFAULT_SENSITIVE_KEYS = [
"password",
"token",
"client_id",
"client_secret",
"Authorization",
"secret",
"aws_access_key_id",
"aws_secret_access_key",
]
Installation
pip install secure-logger
Usage
from secure_logger.decorators import secure_logger
MY_SENSITIVE_KEYS = ["top-secret-password", "equally-secret-value",]
class TestClass(object):
@secure_logger(sensitive_keys=MY_SENSITIVE_KEYS, indent=4)
def test_2(self, test_dict, test_list):
pass
test_dict = {
'insensitive_key': 'you-can-see-me',
'top-secret-password': 'i-am-hidden',
'equally-secret-value': 'so-am-i'
}
test_list = ['foo', 'bar']
o = TestClass()
o.test_2(test_dict=test_dict, test_list=test_list)
Generates log entries of this style and form:
INFO:secure_logger: __main__.TestClass().test_2() keyword args: {
"test_dict": {
"insensitive_key": "you-can-see-me",
"top-secret-password": "*** -- REDACTED -- ***",
"equally-secret-value": "*** -- REDACTED -- ***"
},
"test_list": [
"foo",
"bar"
]
}
Contributing
Pull requests are welcome, and you can also contact Lawrence McDaniel directly.
Getting Started With Local development
- Use the same virtual environment that you use for edx-platform
- Ensure that your Python interpreter to 3.8x
- install black: https://pypi.org/project/black/
- install flake8: https://flake8.pycqa.org/en/latest/
- install flake8-coding: https://pypi.org/project/flake8-coding/
# Run these from within your edx-platform virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements/local.txt
pip install pre-commit black flake8
pre-commit install
Local development good practices
- run
black
on modified code before committing. - run
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- run
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- run
pre-commit run --all-files
before pushing. see: https://pre-commit.com/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
secure-logger-0.1.2.tar.gz
(18.6 kB
view details)
Built Distribution
File details
Details for the file secure-logger-0.1.2.tar.gz
.
File metadata
- Download URL: secure-logger-0.1.2.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc8a6184800e50f2767a5fbce11f72d9974808ede48a13121a73cfe4f670a3ee |
|
MD5 | 0548fc0aa3754207fdb349ed3cc5be2d |
|
BLAKE2b-256 | 33c4edb7b69ee1576477283b4ae4305bf11c331aa50060ef7ba3ab531444e180 |
Provenance
File details
Details for the file secure_logger-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: secure_logger-0.1.2-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efe78560528259a40087b4b1d8fcab6df71af9acc5ea046a5577a3da1a07ab68 |
|
MD5 | b8e6b4085b435c3b995bfc158ae873df |
|
BLAKE2b-256 | 479a9ad1601f196ca5cac96614b18ad29ccb0525208ec2b13250fbe12309208e |