Sensitive Data Logging
Utils for handling sensitive data in logs.
Setup
After installing package to use it's features you need to set default logger and dict configurator class.
Before using and configuring loggers set this things up:
import logging
import logging.config
from sensitive_data_logging.loggers import SensitiveDataLogger
from sensitive_data_logging.configurators import DictConfigurator
logging.setLoggerClass(SensitiveDataLogger)
logging.config.dictConfigClass = DictConfigurator
Configuration
Logger supplied by this package relies on logging dict configuration. In your configuration dict set (or not) variables sensitive_data_in_extra and sensitive_data_in_message.
They can be used in every logger we want to secure, and event in root logger.
sensitive_data_in_extra - is list of keys which supplied in loggers extra data should be moved to sensitive_data
sensitive_data_in_message - is bool whether move loggers message to sensitive_data or not
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': 'DEBUG',
'handlers': ['console'],
},
...
'loggers': {
'first_logger': {
'handlers': ['console'],
},
'second_logger': {
'handlers': ['console'],
'sensitive_data_in_extra': ['phone_number'], # Key 'phone_number' from extra data will be moved to sensitive_data
},
'third_logger': {
'handlers': ['console'],
'sensitive_data_in_message': True, # Whole message and args will be moved to sensitive_data
},
},
})
You can also use sensitive_data_logging.formatters.SensitiveDataFormatter in development environments to prepend sensitive_data to logged message.
Use of logger
With sensitive_data_logging.loggers.SensitiveDataLogger set as default you can use additional keyword argument when logging to explicitly supply sensitive_data:
logger.info('Some log', sensitive_data={'secret': 'value'})
License
The Sensitive Data Logging package is licensed under the FreeBSD License.
Release files for sensitive-data-logging 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sensitive-data-logging-1.0.0.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sensitive_data_logging-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / sensitive-data-logging-1.0.0.tar.gz
| Download URL | sensitive-data-logging-1.0.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d531d15b180e5f4d3bcc7f2f0402f77bff896a8e07221bbf636b9da04bb41e1
|
|
BLAKE2b-256 checksum How to use checksums |
1a39222b0a2b6f8508b574bfd88e49cc0c43f994a762cf5fdad07964c0ef6712
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12
|
Release files / sensitive_data_logging-1.0.0-py3-none-any.whl
| Download URL | sensitive_data_logging-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0a89b7c6dbc85c000bd1b63cbc4048b11232d6e2dc97332bcb59875aab01f8b
|
|
BLAKE2b-256 checksum How to use checksums |
72ca23f459a36f80f009eafe104d8bb1d740573e1aa13b5384f5f9f99cb3cf75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12
|