Skip to main content

python_log_sanitizer

CircleCI PyPI version Maintainability Test Coverage

Python log sanitizer

Instalation

Pipenv

    pipenv install python_log_sanitizer 

Pip

    pip install python_log_sanitizer 

Usage

To run this example please install python-json-logger:

pip install python-json-logger
LOG_CONFIG = {
    "version": 1,
    "formatters": {
        "json": {
            "class": "pythonjsonlogger.jsonlogger.JsonFormatter",
            "format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s"
        }
    },
    "filters": {
        "sanitizer": {
            "()" : "python_log_sanitizer.SanitizerFilter",
            "patterns": ["extra"],
            "placeholder": "*"
        }
    },
    "handlers": {
        "json": {
            "class": "logging.StreamHandler",
            "formatter": "json"
        }
    },
    "loggers": {
        "root": {
            "level": "INFO",
            "handlers": ["json"],
            "filters": ["sanitizer"]
        }
    }
}
import logging

from logging import config

config.dictConfig(LOG_CONFIG) # load log config from dict

logger = logging.getLogger("root") # get root logger instance


logger.info("farofa", extra={"extra": "farofa"}) # log message with extra arguments  

Example output:

{"asctime": "2018-11-04 23:01:55,804", "levelname": "INFO", "module": "<ipython-input-8-f8c68848bfbe>", "message": "farofa", "extra": "*"}

Release files for python-log-sanitizer 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-log-sanitizer 0.0.3
File Size Uploaded
python_log_sanitizer-0.0.3.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-log-sanitizer 0.0.3
File Interpreter ABI Platform
python_log_sanitizer-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / python_log_sanitizer-0.0.3.tar.gz

Download URL python_log_sanitizer-0.0.3.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0232597970e6bb19a765be7e1914d134e86031d80b0699fa6bca773e103728bf
BLAKE2b-256 checksum
How to use checksums
10506dcdf27ecbfe62b1efae620951e85812810c0d693b309e7802dd0d2307ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release files / python_log_sanitizer-0.0.3-py3-none-any.whl

Download URL python_log_sanitizer-0.0.3-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eaea65a0524af8f0ac7e3b6f4f5537e07a7db2f3754d526ed5f131883ea9502d
BLAKE2b-256 checksum
How to use checksums
b1c3954cb0da812b2ffaba2bff3917f05876ee58ae4768d0ae4a9c328daa5bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page