Skip to main content

Utils for logging sensitive data.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sensitive-data-logging-1.0.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

sensitive_data_logging-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sensitive-data-logging-1.0.0.tar.gz.

File metadata

  • Download URL: sensitive-data-logging-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for sensitive-data-logging-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3d531d15b180e5f4d3bcc7f2f0402f77bff896a8e07221bbf636b9da04bb41e1
MD5 aa539737916036b8b0c86c48660055dc
BLAKE2b-256 1a39222b0a2b6f8508b574bfd88e49cc0c43f994a762cf5fdad07964c0ef6712

See more details on using hashes here.

File details

Details for the file sensitive_data_logging-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sensitive_data_logging-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for sensitive_data_logging-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a89b7c6dbc85c000bd1b63cbc4048b11232d6e2dc97332bcb59875aab01f8b
MD5 35bbfe2edd43854e75544727049c4d4c
BLAKE2b-256 72ca23f459a36f80f009eafe104d8bb1d740573e1aa13b5384f5f9f99cb3cf75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page