logging-objects-with-schema 0.3.0__tar.gz → 0.4.0__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.
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/PKG-INFO +1 -11
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/pyproject.toml +15 -8
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/schema_loader.py +33 -25
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/LICENSE +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/README.md +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/__init__.py +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/errors.py +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/py.typed +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/schema_applier.py +0 -0
- {logging_objects_with_schema-0.3.0 → logging_objects_with_schema-0.4.0}/src/logging_objects_with_schema/schema_logger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: logging-objects-with-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Proxy logging wrapper that validates extra fields against a JSON schema.
|
|
5
5
|
Keywords: logging,schema,validation,structured-logging,structured-logs
|
|
6
6
|
Author: Dmitrii Safronov
|
|
@@ -17,19 +17,9 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
17
17
|
Classifier: Intended Audience :: Developers
|
|
18
18
|
Classifier: Topic :: System :: Logging
|
|
19
19
|
Classifier: Typing :: Typed
|
|
20
|
-
Requires-Dist: pytest>=7.0.0 ; extra == 'dev'
|
|
21
|
-
Requires-Dist: pytest-cov>=4.0.0 ; extra == 'dev'
|
|
22
|
-
Requires-Dist: black>=23.0.0 ; extra == 'dev'
|
|
23
|
-
Requires-Dist: isort>=5.12.0 ; extra == 'dev'
|
|
24
|
-
Requires-Dist: flake8>=6.0.0 ; extra == 'dev'
|
|
25
|
-
Requires-Dist: flake8-pyproject>=1.2.3 ; extra == 'dev'
|
|
26
|
-
Requires-Dist: mypy>=1.18.1 ; extra == 'dev'
|
|
27
|
-
Requires-Dist: bandit>=1.8.6 ; extra == 'dev'
|
|
28
|
-
Requires-Dist: pre-commit>=3.5.0 ; extra == 'dev'
|
|
29
20
|
Requires-Python: >=3.10
|
|
30
21
|
Project-URL: Issues, https://github.com/disafronov/python-logging-objects-with-schema/issues
|
|
31
22
|
Project-URL: Source, https://github.com/disafronov/python-logging-objects-with-schema
|
|
32
|
-
Provides-Extra: dev
|
|
33
23
|
Description-Content-Type: text/markdown
|
|
34
24
|
|
|
35
25
|
# python-logging-objects-with-schema
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "logging-objects-with-schema"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Proxy logging wrapper that validates extra fields against a JSON schema."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -35,8 +35,12 @@ classifiers = [
|
|
|
35
35
|
name = "Dmitrii Safronov"
|
|
36
36
|
email = "dhameoelin+logging-objects-with-schema@gmail.com"
|
|
37
37
|
|
|
38
|
-
[project.
|
|
39
|
-
|
|
38
|
+
[project.urls]
|
|
39
|
+
Source = "https://github.com/disafronov/python-logging-objects-with-schema"
|
|
40
|
+
Issues = "https://github.com/disafronov/python-logging-objects-with-schema/issues"
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
40
44
|
"pytest>=7.0.0",
|
|
41
45
|
"pytest-cov>=4.0.0",
|
|
42
46
|
"black>=23.0.0",
|
|
@@ -45,13 +49,10 @@ classifiers = [
|
|
|
45
49
|
"flake8-pyproject>=1.2.3",
|
|
46
50
|
"mypy>=1.18.1",
|
|
47
51
|
"bandit>=1.8.6",
|
|
48
|
-
"pre-commit>=3.5.0"
|
|
52
|
+
"pre-commit>=3.5.0",
|
|
53
|
+
"vulture>=2.0.0"
|
|
49
54
|
]
|
|
50
55
|
|
|
51
|
-
[project.urls]
|
|
52
|
-
Source = "https://github.com/disafronov/python-logging-objects-with-schema"
|
|
53
|
-
Issues = "https://github.com/disafronov/python-logging-objects-with-schema/issues"
|
|
54
|
-
|
|
55
56
|
[tool.isort]
|
|
56
57
|
profile = "black"
|
|
57
58
|
line_length = 88
|
|
@@ -115,3 +116,9 @@ skip_covered = false
|
|
|
115
116
|
|
|
116
117
|
[tool.coverage.html]
|
|
117
118
|
directory = "htmlcov"
|
|
119
|
+
|
|
120
|
+
[tool.vulture]
|
|
121
|
+
min_confidence = 80
|
|
122
|
+
exclude = [ "__pycache__" ]
|
|
123
|
+
ignore_names = [ "cls" ]
|
|
124
|
+
paths = [ "src", "tests" ]
|
|
@@ -177,24 +177,31 @@ def _check_cached_found_file_path() -> Path | None:
|
|
|
177
177
|
When a schema file was found, its absolute path is cached as CWD-independent.
|
|
178
178
|
This function checks if the cached path still exists on disk.
|
|
179
179
|
|
|
180
|
+
Note: This function must be called while holding _path_cache_lock.
|
|
181
|
+
|
|
180
182
|
Returns:
|
|
181
183
|
Cached path if file still exists, None if file was deleted (cache invalidated).
|
|
182
184
|
"""
|
|
183
185
|
global _resolved_schema_path
|
|
184
186
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return None
|
|
188
|
-
|
|
189
|
-
# Schema file was found, absolute path doesn't depend on CWD
|
|
190
|
-
# Return it if it still exists
|
|
191
|
-
if _resolved_schema_path.exists():
|
|
192
|
-
return _resolved_schema_path
|
|
187
|
+
if _resolved_schema_path is None:
|
|
188
|
+
return None
|
|
193
189
|
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
# Check if this is actually a found file cache (not missing file cache)
|
|
191
|
+
# by checking _cached_cwd. We don't need 'global' here since we only read it.
|
|
192
|
+
if _cached_cwd is not None:
|
|
193
|
+
# This path was cached as missing file, not found file
|
|
196
194
|
return None
|
|
197
195
|
|
|
196
|
+
# Schema file was found, absolute path doesn't depend on CWD
|
|
197
|
+
# Return it if it still exists
|
|
198
|
+
if _resolved_schema_path.exists():
|
|
199
|
+
return _resolved_schema_path
|
|
200
|
+
|
|
201
|
+
# Cached file no longer exists; invalidate cache so caller will re-search
|
|
202
|
+
_resolved_schema_path = None
|
|
203
|
+
return None
|
|
204
|
+
|
|
198
205
|
|
|
199
206
|
def _check_cached_missing_file_path() -> Path | None:
|
|
200
207
|
"""Check if cached path for a missing file is still valid.
|
|
@@ -202,26 +209,27 @@ def _check_cached_missing_file_path() -> Path | None:
|
|
|
202
209
|
When a schema file was not found, a path based on CWD is cached.
|
|
203
210
|
This function checks if CWD has changed since caching.
|
|
204
211
|
|
|
212
|
+
Note: This function must be called while holding _path_cache_lock.
|
|
213
|
+
|
|
205
214
|
Returns:
|
|
206
215
|
Cached path if CWD unchanged, None if CWD changed (cache invalidated).
|
|
207
216
|
"""
|
|
208
217
|
global _resolved_schema_path, _cached_cwd
|
|
209
218
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return None
|
|
219
|
+
if _resolved_schema_path is None or _cached_cwd is None:
|
|
220
|
+
return None
|
|
213
221
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
# Cached path is based on CWD when file was not found,
|
|
223
|
+
# check if CWD changed
|
|
224
|
+
current_cwd = _get_current_working_directory()
|
|
225
|
+
if current_cwd != _cached_cwd:
|
|
226
|
+
# CWD changed, invalidate cache and re-search from new CWD
|
|
227
|
+
_resolved_schema_path = None
|
|
228
|
+
_cached_cwd = None
|
|
229
|
+
return None
|
|
222
230
|
|
|
223
|
-
|
|
224
|
-
|
|
231
|
+
# CWD unchanged, return cached path
|
|
232
|
+
return _resolved_schema_path
|
|
225
233
|
|
|
226
234
|
|
|
227
235
|
def _cache_and_return_found_path(found_path: Path) -> Path:
|
|
@@ -800,8 +808,8 @@ def _compile_schema_internal(
|
|
|
800
808
|
given path and forbidden keys set has been observed (including the cases
|
|
801
809
|
when it is missing or invalid), subsequent calls always return the cached
|
|
802
810
|
result without re-reading or re-compiling the schema. To pick up on-disk
|
|
803
|
-
changes to the schema, the application must restart the process.
|
|
804
|
-
|
|
811
|
+
changes to the schema, the application must restart the process. The schema
|
|
812
|
+
is cached process-wide and is thread-safe.
|
|
805
813
|
|
|
806
814
|
Args:
|
|
807
815
|
forbidden_keys: Additional forbidden root keys to check against.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|