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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d810af6254c0c0ccd32eb575fe1fb32ec14a5111cfae22cc5b0d41012887a331 |
|
MD5 | 08ebfd74093374be41c24d2620ee8d9e |
|
BLAKE2b-256 | 4ae70b15371043585a862a769d0503f9f72e60cff7eed29630349b0051f0c6cd |
Close
Hashes for python_log_sanitizer-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb50c184846b1910ba3bd9cd6764126b168dd183205201ca7af1ed3494619ece |
|
MD5 | 6194341948bfd98f6bdb5891d8bc1609 |
|
BLAKE2b-256 | 5abca2895cf929574b8b83528123789525c76807e9b9428e93afb3f115fa3724 |