ContextVars Filter for easily enriching log records
Project description
contextfilter
Small, helper library for logging contextual information in Python 3.7.
Installation
Using pip
$ pip install contextfilter
Usage
import logging
from contextfilter import ContextFilter, set_entry, set_entries
logger = logging.getLogger("test")
logger.addFilter(ContextFilter())
set_entry("request_id", 3)
# or
set_entries(request_id=3)
logger.info("test")
# Log record will contain the attribute request_id with value 3
Contributing
To work on the contextfilter
codebase, you'll want to fork the project and clone it locally and install the required dependencies via poetry:
$ git clone git@github.com:{USER}/contextfilter.git
$ make install
To run tests and linters use command below:
$ make lint && make test
If you want to run only tests or linters you can explicitly specify which test environment you want to run, e.g.:
$ make lint-black
License
contextfilter
is licensed under the MIT license. See the license file for details.
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
contextfilter-0.2.0.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for contextfilter-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 608c59c750d536ee917f8f9a1678c3a424d40d0dd5e54c9eabc7a8f98a6a5464 |
|
MD5 | 203d1a82fa0533a469750e3a825ecdbc |
|
BLAKE2b-256 | 47bfd7aa851abe0185e5372f69f37a489f41e4af8768593a4c3e4ce4b92d9145 |