fastapi-commons 0.4.2__tar.gz → 0.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastapi_commons-0.4.2/src/fastapi_commons.egg-info → fastapi_commons-0.4.3}/PKG-INFO +1 -1
- fastapi_commons-0.4.3/src/fastapi_commons/log/filters.py +28 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3/src/fastapi_commons.egg-info}/PKG-INFO +1 -1
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons.egg-info/SOURCES.txt +2 -0
- fastapi_commons-0.4.3/tests/unit/__init__.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.coveragerc +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.env_template +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.github/workflows/checks.yml +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.github/workflows/python-publish.yaml +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.github/workflows/release-on-tag-push.yml +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.gitignore +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.pre-commit-config.yaml +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/.python-version +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/AUTHORS.rst +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/CHANGELOG.rst +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/LICENSE +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/README.md +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/README.rst +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/pyproject.toml +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/setup.cfg +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/__init__.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/auth.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/conf.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/handlers.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/helpers.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/instrumentation.py +0 -0
- {fastapi_commons-0.4.2/src/fastapi_commons/middleware → fastapi_commons-0.4.3/src/fastapi_commons/log}/__init__.py +0 -0
- {fastapi_commons-0.4.2/tests → fastapi_commons-0.4.3/src/fastapi_commons/middleware}/__init__.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/correlation_id.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/log_context.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/prometheus.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons.egg-info/dependency_links.txt +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons.egg-info/requires.txt +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons.egg-info/top_level.txt +0 -0
- {fastapi_commons-0.4.2/tests/unit → fastapi_commons-0.4.3/tests}/__init__.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/tests/conftest.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/tests/unit/test_poc.py +0 -0
- {fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/uv.lock +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from fastapi_commons.middleware.correlation_id import correlation_id_ctx
|
|
4
|
+
from fastapi_commons.middleware.log_context import log_context
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LogContextFilter(logging.Filter):
|
|
8
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
|
9
|
+
if not (context := log_context.get()):
|
|
10
|
+
log_context.set({})
|
|
11
|
+
else:
|
|
12
|
+
for key, value in context.items():
|
|
13
|
+
if value:
|
|
14
|
+
setattr(record, key, value)
|
|
15
|
+
|
|
16
|
+
return True
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CorrelationIDFilter(logging.Filter):
|
|
20
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
|
21
|
+
try:
|
|
22
|
+
correlation_id = correlation_id_ctx.get()
|
|
23
|
+
if correlation_id:
|
|
24
|
+
record.correlation_id = correlation_id
|
|
25
|
+
except LookupError:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
return True
|
|
@@ -24,6 +24,8 @@ src/fastapi_commons.egg-info/SOURCES.txt
|
|
|
24
24
|
src/fastapi_commons.egg-info/dependency_links.txt
|
|
25
25
|
src/fastapi_commons.egg-info/requires.txt
|
|
26
26
|
src/fastapi_commons.egg-info/top_level.txt
|
|
27
|
+
src/fastapi_commons/log/__init__.py
|
|
28
|
+
src/fastapi_commons/log/filters.py
|
|
27
29
|
src/fastapi_commons/middleware/__init__.py
|
|
28
30
|
src/fastapi_commons/middleware/correlation_id.py
|
|
29
31
|
src/fastapi_commons/middleware/log_context.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_commons-0.4.2/tests → fastapi_commons-0.4.3/src/fastapi_commons/middleware}/__init__.py
RENAMED
|
File without changes
|
{fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/correlation_id.py
RENAMED
|
File without changes
|
{fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/log_context.py
RENAMED
|
File without changes
|
{fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons/middleware/prometheus.py
RENAMED
|
File without changes
|
{fastapi_commons-0.4.2 → fastapi_commons-0.4.3}/src/fastapi_commons.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|