Log Sanitizer
Project description
python_log_sanitizer
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": "*"}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_log_sanitizer-0.0.3.tar.gz.
File metadata
- Download URL: python_log_sanitizer-0.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0232597970e6bb19a765be7e1914d134e86031d80b0699fa6bca773e103728bf
|
|
| MD5 |
ec06e0b514eff590daff60de26b4b911
|
|
| BLAKE2b-256 |
10506dcdf27ecbfe62b1efae620951e85812810c0d693b309e7802dd0d2307ef
|
File details
Details for the file python_log_sanitizer-0.0.3-py3-none-any.whl.
File metadata
- Download URL: python_log_sanitizer-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaea65a0524af8f0ac7e3b6f4f5537e07a7db2f3754d526ed5f131883ea9502d
|
|
| MD5 |
8510f57ef740d1763968633d8be69ed7
|
|
| BLAKE2b-256 |
b1c3954cb0da812b2ffaba2bff3917f05876ee58ae4768d0ae4a9c328daa5bf3
|