yapl-kit 0.4.0__tar.gz → 0.4.1__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.
Files changed (91) hide show
  1. yapl_kit-0.4.1/PKG-INFO +92 -0
  2. yapl_kit-0.4.1/README.md +73 -0
  3. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/Cargo.lock +7 -7
  4. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/Cargo.toml +2 -2
  5. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/src/copying.rs +19 -12
  6. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/src/encoding.rs +1 -1
  7. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/src/plan.rs +1 -12
  8. yapl_kit-0.4.1/pyproject.toml +194 -0
  9. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/setup.py +2 -1
  10. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/_handlers.py +13 -2
  11. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/_native.pyi +5 -2
  12. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/_optional.py +3 -4
  13. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/config.py +31 -27
  14. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/buffering/capture.py +8 -8
  15. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/buffering/context.py +44 -35
  16. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/buffering/flush.py +9 -4
  17. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/buffering/models.py +87 -32
  18. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/colors.py +2 -1
  19. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/models.py +7 -9
  20. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/plain.py +28 -22
  21. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/registry.py +8 -6
  22. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/structured.py +5 -5
  23. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/text.py +0 -2
  24. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/_helpers.py +2 -1
  25. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/formatters.py +1 -3
  26. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/policy.py +40 -7
  27. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/processors.py +31 -15
  28. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/structured.py +74 -49
  29. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/integrations/asgi.py +3 -3
  30. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/integrations/jobs.py +7 -7
  31. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/metrics.py +51 -12
  32. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/opentelemetry.py +15 -9
  33. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/handler.py +103 -65
  34. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/models.py +8 -5
  35. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/policy.py +0 -2
  36. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/queue.py +2 -4
  37. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/worker.py +6 -2
  38. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/tracing.py +2 -1
  39. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/webhook/__init__.py +2 -1
  40. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/webhook/client.py +38 -36
  41. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/webhook/handler.py +81 -51
  42. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/webhook/models.py +26 -15
  43. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/webhook/payloads.py +7 -7
  44. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/factory.py +251 -189
  45. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/filters/contracts.py +19 -4
  46. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/filters/enrichment.py +2 -5
  47. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/filters/noise.py +62 -41
  48. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/filters/suppression.py +6 -6
  49. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/levels.py +28 -14
  50. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/logger.py +31 -60
  51. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/stack/callsite.py +1 -1
  52. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/stack/tracer.py +24 -15
  53. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/status.py +12 -4
  54. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/testing.py +0 -2
  55. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/types.py +3 -1
  56. yapl_kit-0.4.1/src/yapl_kit.egg-info/PKG-INFO +92 -0
  57. yapl_kit-0.4.1/src/yapl_kit.egg-info/requires.txt +6 -0
  58. yapl_kit-0.4.0/PKG-INFO +0 -13
  59. yapl_kit-0.4.0/README.md +0 -61
  60. yapl_kit-0.4.0/pyproject.toml +0 -112
  61. yapl_kit-0.4.0/src/yapl_kit.egg-info/PKG-INFO +0 -13
  62. yapl_kit-0.4.0/src/yapl_kit.egg-info/requires.txt +0 -6
  63. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/LICENSE +0 -0
  64. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/MANIFEST.in +0 -0
  65. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/README.md +0 -0
  66. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/src/lib.rs +0 -0
  67. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/native/src/trimming.rs +0 -0
  68. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/setup.cfg +0 -0
  69. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/__init__.py +0 -0
  70. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/_validation.py +0 -0
  71. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/context.py +0 -0
  72. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/buffering/__init__.py +0 -0
  73. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/__init__.py +0 -0
  74. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/policy.py +0 -0
  75. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/coloring/themes.py +0 -0
  76. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/__init__.py +0 -0
  77. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/_types.py +0 -0
  78. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/json.py +0 -0
  79. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/logfmt.py +0 -0
  80. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/plain.py +0 -0
  81. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/formatting/text.py +0 -0
  82. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/integrations/__init__.py +0 -0
  83. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/extensions/queueing/__init__.py +0 -0
  84. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/filters/__init__.py +0 -0
  85. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/py.typed +0 -0
  86. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl/stack/__init__.py +0 -0
  87. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl_kit/__init__.py +0 -0
  88. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl_kit/py.typed +0 -0
  89. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl_kit.egg-info/SOURCES.txt +0 -0
  90. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl_kit.egg-info/dependency_links.txt +0 -0
  91. {yapl_kit-0.4.0 → yapl_kit-0.4.1}/src/yapl_kit.egg-info/top_level.txt +0 -0
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: yapl-kit
3
+ Version: 0.4.1
4
+ Summary: YetAnotherPythonLogger - a minimal, extensible logging toolkit built on top of Python's standard logging module.
5
+ Author: SirKaiMartin
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.13
9
+ Classifier: Programming Language :: Python :: 3.14
10
+ Classifier: Programming Language :: Python :: 3.15
11
+ Requires-Python: >=3.13
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: webhook
15
+ Requires-Dist: httpx>=0.29.0; extra == "webhook"
16
+ Provides-Extra: opentelemetry
17
+ Requires-Dist: opentelemetry-api>=1.45.3; extra == "opentelemetry"
18
+ Dynamic: license-file
19
+
20
+ <p align="center">
21
+ <img src="https://yapl.yapl-kit.workers.dev/branding/yapl_kit_icon_banner_right.png" alt="YAPL: Yet Another Python Logger" width="560">
22
+ </p>
23
+
24
+ <h1 align="center">YAPL</h1>
25
+
26
+ <p align="center">
27
+ Structured context and bounded background delivery for Python's standard <code>logging</code> module.
28
+ </p>
29
+
30
+ <p align="center">
31
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/v/yapl-kit?color=blue&label=PyPI" alt="PyPI"></a>
32
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/pyversions/yapl-kit?label=Python" alt="Python 3.13+"></a>
33
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/l/yapl-kit?label=License" alt="MIT License"></a>
34
+ <a href="https://yapl.yapl-kit.workers.dev/guide/"><img src="https://img.shields.io/badge/docs-yapl--kit-teal" alt="Documentation"></a>
35
+ </p>
36
+
37
+ ## Highlights
38
+
39
+ - Add structured fields to log calls or scope them to a context.
40
+ - Use bound logger views for reusable fields such as a service or component name.
41
+ - Move formatting and output work to a bounded queue when background delivery is useful.
42
+ - Extend logging with bundled formatting, coloring, buffering, stack helpers, webhooks, and OpenTelemetry support.
43
+ - Install the core package without third-party Python runtime dependencies; webhook and OpenTelemetry dependencies are optional extras.
44
+
45
+ ## Installation
46
+
47
+ YAPL requires GIL-enabled CPython 3.13 or newer.
48
+
49
+ ```bash
50
+ pip install yapl-kit
51
+ ```
52
+
53
+ Or add it to a `uv` project:
54
+
55
+ ```bash
56
+ uv add yapl-kit
57
+ ```
58
+
59
+ Install optional integrations only when you need them:
60
+
61
+ ```bash
62
+ pip install 'yapl-kit[webhook]'
63
+ pip install 'yapl-kit[opentelemetry]'
64
+ ```
65
+
66
+ ## Quick start
67
+
68
+ ```python
69
+ import yapl
70
+
71
+ yapl.setup_logging(level="INFO", outputs=("stdout",), format="text")
72
+ log = yapl.get_logger(__name__)
73
+
74
+ log.info("Request received", request_id="req-42")
75
+
76
+ with yapl.context(request_id="req-43"):
77
+ log.info("Processing request")
78
+
79
+ yapl.shutdown_logging()
80
+ ```
81
+
82
+ The main import is `yapl`. For scripts that need setup and shutdown around a block, use `yapl.logging_session(...)` instead.
83
+
84
+ ## Documentation
85
+
86
+ | Resource | What it covers |
87
+ | --- | --- |
88
+ | [User guide](https://yapl.yapl-kit.workers.dev/guide/) | Setup, configuration, and output formats |
89
+ | [Native build guide](https://yapl.yapl-kit.workers.dev/native-build/) | Source builds and native extension details |
90
+ | [Demos](https://yapl.yapl-kit.workers.dev/demos/) | Runnable examples and integrations |
91
+ | [Benchmarks](https://yapl.yapl-kit.workers.dev/benchmarks/) | Throughput and latency results |
92
+ | [Changelog](https://yapl.yapl-kit.workers.dev/changelogs/) | Release notes |
@@ -0,0 +1,73 @@
1
+ <p align="center">
2
+ <img src="https://yapl.yapl-kit.workers.dev/branding/yapl_kit_icon_banner_right.png" alt="YAPL: Yet Another Python Logger" width="560">
3
+ </p>
4
+
5
+ <h1 align="center">YAPL</h1>
6
+
7
+ <p align="center">
8
+ Structured context and bounded background delivery for Python's standard <code>logging</code> module.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/v/yapl-kit?color=blue&label=PyPI" alt="PyPI"></a>
13
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/pyversions/yapl-kit?label=Python" alt="Python 3.13+"></a>
14
+ <a href="https://pypi.org/project/yapl-kit/"><img src="https://img.shields.io/pypi/l/yapl-kit?label=License" alt="MIT License"></a>
15
+ <a href="https://yapl.yapl-kit.workers.dev/guide/"><img src="https://img.shields.io/badge/docs-yapl--kit-teal" alt="Documentation"></a>
16
+ </p>
17
+
18
+ ## Highlights
19
+
20
+ - Add structured fields to log calls or scope them to a context.
21
+ - Use bound logger views for reusable fields such as a service or component name.
22
+ - Move formatting and output work to a bounded queue when background delivery is useful.
23
+ - Extend logging with bundled formatting, coloring, buffering, stack helpers, webhooks, and OpenTelemetry support.
24
+ - Install the core package without third-party Python runtime dependencies; webhook and OpenTelemetry dependencies are optional extras.
25
+
26
+ ## Installation
27
+
28
+ YAPL requires GIL-enabled CPython 3.13 or newer.
29
+
30
+ ```bash
31
+ pip install yapl-kit
32
+ ```
33
+
34
+ Or add it to a `uv` project:
35
+
36
+ ```bash
37
+ uv add yapl-kit
38
+ ```
39
+
40
+ Install optional integrations only when you need them:
41
+
42
+ ```bash
43
+ pip install 'yapl-kit[webhook]'
44
+ pip install 'yapl-kit[opentelemetry]'
45
+ ```
46
+
47
+ ## Quick start
48
+
49
+ ```python
50
+ import yapl
51
+
52
+ yapl.setup_logging(level="INFO", outputs=("stdout",), format="text")
53
+ log = yapl.get_logger(__name__)
54
+
55
+ log.info("Request received", request_id="req-42")
56
+
57
+ with yapl.context(request_id="req-43"):
58
+ log.info("Processing request")
59
+
60
+ yapl.shutdown_logging()
61
+ ```
62
+
63
+ The main import is `yapl`. For scripts that need setup and shutdown around a block, use `yapl.logging_session(...)` instead.
64
+
65
+ ## Documentation
66
+
67
+ | Resource | What it covers |
68
+ | --- | --- |
69
+ | [User guide](https://yapl.yapl-kit.workers.dev/guide/) | Setup, configuration, and output formats |
70
+ | [Native build guide](https://yapl.yapl-kit.workers.dev/native-build/) | Source builds and native extension details |
71
+ | [Demos](https://yapl.yapl-kit.workers.dev/demos/) | Runnable examples and integrations |
72
+ | [Benchmarks](https://yapl.yapl-kit.workers.dev/benchmarks/) | Throughput and latency results |
73
+ | [Changelog](https://yapl.yapl-kit.workers.dev/changelogs/) | Release notes |
@@ -10,9 +10,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
10
10
 
11
11
  [[package]]
12
12
  name = "itoa"
13
- version = "1.0.18"
13
+ version = "1.0.19"
14
14
  source = "registry+https://github.com/rust-lang/crates.io-index"
15
- checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
15
+ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
16
16
 
17
17
  [[package]]
18
18
  name = "libc"
@@ -157,9 +157,9 @@ dependencies = [
157
157
 
158
158
  [[package]]
159
159
  name = "syn"
160
- version = "3.0.9"
160
+ version = "3.0.10"
161
161
  source = "registry+https://github.com/rust-lang/crates.io-index"
162
- checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
162
+ checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
163
163
  dependencies = [
164
164
  "proc-macro2",
165
165
  "quote",
@@ -168,9 +168,9 @@ dependencies = [
168
168
 
169
169
  [[package]]
170
170
  name = "target-lexicon"
171
- version = "0.13.5"
171
+ version = "0.13.6"
172
172
  source = "registry+https://github.com/rust-lang/crates.io-index"
173
- checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
173
+ checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
174
174
 
175
175
  [[package]]
176
176
  name = "unicode-ident"
@@ -180,7 +180,7 @@ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
180
180
 
181
181
  [[package]]
182
182
  name = "yapl-native"
183
- version = "0.4.0"
183
+ version = "0.4.1"
184
184
  dependencies = [
185
185
  "pyo3",
186
186
  "serde_json",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "yapl-native"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  edition = "2021"
5
5
  rust-version = "1.85"
6
6
  publish = false
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
12
12
 
13
13
  [dependencies]
14
14
  pyo3 = { version = "0.30.1", features = ["extension-module", "abi3-py313"] }
15
- serde_json = "1.0"
15
+ serde_json = "1.0.154"
16
16
 
17
17
  [profile.release]
18
18
  lto = "thin"
@@ -1,9 +1,12 @@
1
1
  use std::collections::{HashMap, HashSet};
2
2
 
3
- use pyo3::exceptions::{PyAttributeError, PyException, PyRecursionError, PyTypeError};
3
+ use pyo3::exceptions::{
4
+ PyAttributeError, PyBaseException, PyException, PyRecursionError, PyTypeError,
5
+ };
4
6
  use pyo3::prelude::*;
5
7
  use pyo3::types::{
6
- PyBool, PyBytes, PyComplex, PyDict, PyFloat, PyInt, PyList, PyString, PyTuple, PyType,
8
+ PyBool, PyBytes, PyComplex, PyDict, PyFloat, PyInt, PyList, PyString, PyTraceback, PyTuple,
9
+ PyType,
7
10
  };
8
11
 
9
12
  type Memo<'py> = HashMap<usize, (Bound<'py, PyAny>, Bound<'py, PyAny>)>;
@@ -74,7 +77,8 @@ pub fn entries<'py>(
74
77
 
75
78
  /// Isolate graphs in Rust, including cycles and Python object copy protocols.
76
79
  /// Failed protocols restart with a fresh native container memo; uncopyable
77
- /// leaves remain shared. No Python copying implementation is used.
80
+ /// leaves remain shared. Share exceptions and tracebacks because copy reductions
81
+ /// omit the live traceback and exception chain. No Python copying implementation is used.
78
82
  #[pyfunction]
79
83
  pub fn isolate(value: &Bound<'_, PyAny>) -> PyResult<Py<PyAny>> {
80
84
  match copy(
@@ -118,7 +122,10 @@ fn copy<'py>(
118
122
  tolerant: bool,
119
123
  depth: usize,
120
124
  ) -> PyResult<Bound<'py, PyAny>> {
121
- if atomic(value) {
125
+ if atomic(value)
126
+ || value.is_instance_of::<PyBaseException>()
127
+ || value.is_instance_of::<PyTraceback>()
128
+ {
122
129
  return Ok(value.clone());
123
130
  }
124
131
  let identity = value.as_ptr() as usize;
@@ -171,14 +178,14 @@ fn copy<'py>(
171
178
  return Ok(result);
172
179
  }
173
180
  let result = if tolerant {
174
- match copy(
175
- value,
176
- &mut HashMap::new(),
177
- &PyDict::new(value.py()),
178
- false,
179
- depth + 1,
180
- ) {
181
- Ok(result) => result,
181
+ let mut attempt_memo = HashMap::new();
182
+ let attempt_hooks = hooks.copy()?;
183
+ match copy(value, &mut attempt_memo, &attempt_hooks, false, depth) {
184
+ Ok(result) => {
185
+ hooks.update(attempt_hooks.as_mapping())?;
186
+ memo.extend(attempt_memo);
187
+ result
188
+ }
182
189
  Err(error) if error.is_instance_of::<pyo3::exceptions::PyMemoryError>(value.py()) => {
183
190
  return Err(error)
184
191
  }
@@ -361,7 +361,7 @@ pub fn logfmt(event: &Bound<'_, PyDict>) -> PyResult<Py<PyAny>> {
361
361
  let items = entries(flat.as_any())?;
362
362
  let mut out = Vec::with_capacity(256);
363
363
  for (key, value) in items {
364
- if value.is_none() || value.eq(PyDict::new(event.py()))? {
364
+ if value.is_none() || value.cast::<PyDict>().is_ok_and(|dict| dict.is_empty()) {
365
365
  continue;
366
366
  }
367
367
  if !out.is_empty() {
@@ -203,11 +203,6 @@ impl CompiledPlan {
203
203
  Output::Event | Output::Logfmt => {
204
204
  let result = PyDict::new(py);
205
205
  for (key, value) in selected {
206
- let value = if !self.projected {
207
- value
208
- } else {
209
- copying::isolate(&value)?.into_bound(py)
210
- };
211
206
  result.set_item(key, value)?;
212
207
  }
213
208
  if matches!(self.output, Output::Logfmt) {
@@ -227,13 +222,6 @@ impl CompiledPlan {
227
222
  }
228
223
  encoding::key(&mut out, key)?;
229
224
  out.push(b':');
230
- let projected;
231
- let value = if !self.projected {
232
- value
233
- } else {
234
- projected = copying::isolate(value)?.into_bound(py);
235
- &projected
236
- };
237
225
  encoding::write(&mut out, value, &mut ancestors)?;
238
226
  }
239
227
  out.push(b'}');
@@ -246,6 +234,7 @@ impl CompiledPlan {
246
234
  }
247
235
  }
248
236
 
237
+ /// Select values from the processed event without running copy hooks after policy.
249
238
  fn select<'py>(
250
239
  &self,
251
240
  event: &Bound<'py, PyDict>,
@@ -0,0 +1,194 @@
1
+ [project]
2
+ name = "yapl-kit"
3
+ version = "0.4.1"
4
+ description = "YetAnotherPythonLogger - a minimal, extensible logging toolkit built on top of Python's standard logging module."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "SirKaiMartin" }
8
+ ]
9
+ license = "MIT"
10
+ license-files = ["LICENSE"]
11
+ requires-python = ">=3.13"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Programming Language :: Python :: 3.15",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ webhook = ["httpx>=0.29.0"]
21
+ opentelemetry = ["opentelemetry-api>=1.45.3"]
22
+
23
+ [build-system]
24
+ requires = ["setuptools>=84.2.1,<85", "setuptools-rust>=1.14.0,<2"]
25
+ build-backend = "setuptools.build_meta"
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ["src"]
29
+ include = ["yapl", "yapl.*", "yapl_kit"]
30
+
31
+ [tool.setuptools.package-data]
32
+ yapl = ["py.typed", "*.pyi"]
33
+ yapl_kit = ["py.typed"]
34
+
35
+ [tool.setuptools.exclude-package-data]
36
+ yapl = ["*.pyd", "*.so"]
37
+
38
+ [tool.cibuildwheel]
39
+ build = "cp313-* cp314-* cp315-*"
40
+ skip = "*-musllinux_*"
41
+ archs = ["native"]
42
+ test-sources = ["tests", "docs/examples", "pyproject.toml"]
43
+ test-requires = ["pytest>=9.2.0"]
44
+ test-extras = ["webhook", "opentelemetry"]
45
+ test-command = "python -m pytest tests/unit"
46
+
47
+ [tool.cibuildwheel.linux]
48
+ before-all = "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable"
49
+ environment = { PATH = "$HOME/.cargo/bin:$PATH", RUSTUP_TOOLCHAIN = "stable" }
50
+ manylinux-x86_64-image = "manylinux_2_28"
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "pytest>=9.2.0",
55
+ "ruff>=0.17.6",
56
+ "ty>=1.0.0",
57
+ ]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ pythonpath = ["tests"]
62
+ filterwarnings = ["error"]
63
+ markers = [
64
+ "performance: caller-latency, throughput, and backpressure regression coverage",
65
+ ]
66
+
67
+ [tool.ruff]
68
+ target-version = "py313"
69
+ line-length = 100
70
+ unsafe-fixes = false
71
+
72
+ [tool.ruff.lint]
73
+ select = [
74
+ # Python correctness, import order, and syntax for the supported runtime.
75
+ "A", # builtin name shadowing
76
+ "E",
77
+ "F",
78
+ "I",
79
+ "PLC0205", # keep slot declarations iterable for introspection
80
+ "PLE", # Pylint errors such as invalid calls and control flow
81
+ "PLR0124", # comparisons of a value with itself
82
+ "PLR0133", # comparisons between constants
83
+ "PLR0206", # properties must be callable without arguments
84
+ "UP",
85
+ "W",
86
+ "YTT", # brittle Python version checks
87
+
88
+ # Runtime safety, concurrency, resource handling, and optional imports.
89
+ "ASYNC",
90
+ "B",
91
+ "DTZ",
92
+ "PLW", # includes ineffective locks and unsafe subprocess options
93
+ "S",
94
+ "TID253", # keep optional dependencies out of runtime module imports
95
+
96
+ # Logging calls and exception handling, including eager message rendering.
97
+ "BLE001",
98
+ "EM",
99
+ "G",
100
+ "LOG",
101
+ "TRY",
102
+
103
+ # API documentation, typed function boundaries, stubs, and suppression codes.
104
+ "ANN",
105
+ "D101", # document public classes
106
+ "D102", # document public methods
107
+ "D103", # document public functions
108
+ "D417", # check parameter coverage in existing argument sections
109
+ "PGH003",
110
+ "PGH004",
111
+ "PGH005",
112
+ "PYI",
113
+ "TC",
114
+
115
+ # Complexity, readable control flow, and avoidable work.
116
+ "ARG",
117
+ "C4",
118
+ "C90",
119
+ "ERA",
120
+ "FBT",
121
+ "FURB",
122
+ "ISC003",
123
+ "ISC004", # catch missing commas between strings in collections
124
+ "PERF",
125
+ "PIE",
126
+ "PTH",
127
+ "RET",
128
+ "RSE",
129
+ "RUF",
130
+ "SIM",
131
+ "SLOT",
132
+
133
+ # Pytest correctness and stray debugger or console calls.
134
+ "PT",
135
+ "T10",
136
+ "T20",
137
+ ]
138
+
139
+ ignore = [
140
+ # The formatter owns line wrapping and may leave long literals intact.
141
+ "E501",
142
+ # Keep informative messages on standard exception types.
143
+ "TRY003",
144
+ ]
145
+
146
+ [tool.ruff.lint.per-file-ignores]
147
+ "tests/**/*.py" = [
148
+ "S101", # pytest uses assert for test expectations
149
+ "S105", # tests use synthetic credentials
150
+ "S106",
151
+ "T20", # test helpers can print diagnostics
152
+ ]
153
+ "docs/examples/**/*.py" = [
154
+ "T20", # runnable examples and benchmarks report to the console
155
+ ]
156
+ # Package source owns the public API docs and the optional dependency boundary.
157
+ "!src/yapl/**/*.py" = ["D101", "D102", "D103", "D417", "TID253"]
158
+
159
+ [tool.ruff.lint.flake8-tidy-imports]
160
+ banned-module-level-imports = ["httpx", "opentelemetry"]
161
+
162
+ [tool.ruff.lint.pydocstyle]
163
+ convention = "google"
164
+
165
+ [tool.ruff.lint.flake8-pytest-style]
166
+ fixture-parentheses = false
167
+ mark-parentheses = false
168
+
169
+ [tool.ruff.lint.flake8-unused-arguments]
170
+ ignore-variadic-names = true
171
+
172
+ [tool.ruff.lint.mccabe]
173
+ max-complexity = 12
174
+
175
+ [tool.ruff.lint.isort]
176
+ lines-after-imports = 2
177
+ from-first = false
178
+ relative-imports-order = "closest-to-furthest"
179
+ force-sort-within-sections = true
180
+ force-wrap-aliases = true
181
+ combine-as-imports = true
182
+ section-order = [
183
+ "future",
184
+ "standard-library",
185
+ "third-party",
186
+ "first-party",
187
+ "local-folder",
188
+ ]
189
+
190
+ [tool.ty.src]
191
+ include = ["src", "tests", "docs/examples"]
192
+
193
+ [tool.ty.rules]
194
+ all = "error"
@@ -19,7 +19,8 @@ class FreshBuildRust(build_rust):
19
19
 
20
20
  supported = sys.implementation.name == "cpython" and not sysconfig.get_config_var("Py_GIL_DISABLED")
21
21
  if not supported:
22
- raise RuntimeError("YAPL requires GIL-enabled CPython 3.13 or newer")
22
+ msg = "YAPL requires GIL-enabled CPython 3.13 or newer"
23
+ raise RuntimeError(msg)
23
24
 
24
25
  setup(
25
26
  cmdclass={"build_rust": FreshBuildRust},
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  from collections.abc import Callable
4
2
  import contextlib
5
3
  import logging
@@ -12,6 +10,7 @@ class _SinkErrorObserver(logging.Handler):
12
10
  """Report stdlib-handled I/O errors to the owning queue without changing emission."""
13
11
 
14
12
  _delivery_error_callback: Callable[[logging.LogRecord, Exception], None] | None = None
13
+ _closed: bool
15
14
 
16
15
  def set_delivery_error_callback(
17
16
  self,
@@ -43,6 +42,18 @@ class OwnedStreamHandler(_SinkErrorObserver, logging.StreamHandler[TextIO]):
43
42
  class OwnedFileHandler(_SinkErrorObserver, logging.FileHandler):
44
43
  """File sink with observable stdlib delivery failures."""
45
44
 
45
+ @override
46
+ def emit(self, record: logging.LogRecord) -> None:
47
+ """Check retirement under the stdlib handler lock before opening the file."""
48
+ if not self._closed:
49
+ super().emit(record)
50
+
46
51
 
47
52
  class OwnedRotatingFileHandler(_SinkErrorObserver, RotatingFileHandler):
48
53
  """Rotating file sink with observable stdlib delivery failures."""
54
+
55
+ @override
56
+ def emit(self, record: logging.LogRecord) -> None:
57
+ """Skip both rollover and writing after this sink has retired."""
58
+ if not self._closed:
59
+ super().emit(record)
@@ -33,9 +33,12 @@ def compile_plan(
33
33
  def compile_plan(
34
34
  policy: object | None = None, output_format: Literal["bytes"] = ...
35
35
  ) -> CompiledPlan[bytes]: ...
36
- def isolate(value: Any) -> Any: ...
36
+ @overload
37
+ def isolate(value: dict[str, Any]) -> dict[str, Any]: ...
38
+ @overload
39
+ def isolate(value: object) -> object: ...
37
40
  def to_json_text(
38
- value: Any, *, style: Literal["compact", "spaced", "pretty"] = "compact"
41
+ value: object, *, style: Literal["compact", "spaced", "pretty"] = "compact"
39
42
  ) -> str: ...
40
43
  def json_fragments(payload: dict[str, Any]) -> list[tuple[str, str, str]]: ...
41
44
  def serialize_payload(payload: dict[str, Any]) -> bytes: ...
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  from importlib import import_module
4
2
  from types import ModuleType
5
3
 
@@ -14,7 +12,8 @@ def require_optional_dependency(module_name: str, *, extra: str, feature: str) -
14
12
  module_name == missing_module or module_name.startswith(f"{missing_module}.")
15
13
  ):
16
14
  raise
17
- raise ImportError(
15
+ msg = (
18
16
  f"{feature} requires the '{extra}' extra. "
19
17
  f"Install it with 'pip install yapl-kit[{extra}]'."
20
- ) from exc
18
+ )
19
+ raise ImportError(msg) from exc