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
Close
Hashes for python_log_sanitizer-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0232597970e6bb19a765be7e1914d134e86031d80b0699fa6bca773e103728bf |
|
MD5 | ec06e0b514eff590daff60de26b4b911 |
|
BLAKE2b-256 | 10506dcdf27ecbfe62b1efae620951e85812810c0d693b309e7802dd0d2307ef |
Close
Hashes for python_log_sanitizer-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaea65a0524af8f0ac7e3b6f4f5537e07a7db2f3754d526ed5f131883ea9502d |
|
MD5 | 8510f57ef740d1763968633d8be69ed7 |
|
BLAKE2b-256 | b1c3954cb0da812b2ffaba2bff3917f05876ee58ae4768d0ae4a9c328daa5bf3 |