bookalimo 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
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.
- bookalimo/_logging.py +14 -20
- {bookalimo-0.1.4.dist-info → bookalimo-0.1.5.dist-info}/METADATA +1 -1
- {bookalimo-0.1.4.dist-info → bookalimo-0.1.5.dist-info}/RECORD +6 -6
- {bookalimo-0.1.4.dist-info → bookalimo-0.1.5.dist-info}/WHEEL +0 -0
- {bookalimo-0.1.4.dist-info → bookalimo-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {bookalimo-0.1.4.dist-info → bookalimo-0.1.5.dist-info}/top_level.txt +0 -0
bookalimo/_logging.py
CHANGED
@@ -8,9 +8,15 @@ from __future__ import annotations
|
|
8
8
|
import logging
|
9
9
|
import os
|
10
10
|
import re
|
11
|
-
from collections.abc import Iterable, Mapping
|
11
|
+
from collections.abc import Awaitable, Iterable, Mapping
|
12
|
+
from functools import wraps
|
12
13
|
from time import perf_counter
|
13
|
-
from typing import Any, Callable
|
14
|
+
from typing import Any, Callable, TypeVar
|
15
|
+
|
16
|
+
from typing_extensions import ParamSpec
|
17
|
+
|
18
|
+
P = ParamSpec("P")
|
19
|
+
R = TypeVar("R")
|
14
20
|
|
15
21
|
logger = logging.getLogger("bookalimo")
|
16
22
|
logger.addHandler(logging.NullHandler())
|
@@ -178,27 +184,19 @@ def log_call(
|
|
178
184
|
include_params: Iterable[str] | None = None,
|
179
185
|
transforms: Mapping[str, Callable[[Any], Any]] | None = None,
|
180
186
|
operation: str | None = None,
|
181
|
-
) -> Callable[[Callable[
|
182
|
-
"""
|
183
|
-
Decorator for async SDK methods.
|
184
|
-
- DEBUG: logs start/end with sanitized params + duration
|
185
|
-
- WARNING: logs errors (sanitized). No overhead when DEBUG is off.
|
186
|
-
"""
|
187
|
+
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[R]]]:
|
187
188
|
include = set(include_params or [])
|
188
189
|
transforms = transforms or {}
|
189
190
|
|
190
|
-
def _decorate(fn: Callable[
|
191
|
-
|
191
|
+
def _decorate(fn: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]:
|
192
|
+
@wraps(fn)
|
193
|
+
async def _async_wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
|
192
194
|
log = get_logger("wrapper")
|
193
195
|
op = operation or fn.__name__
|
194
196
|
|
195
|
-
# Fast path: if debug disabled, skip param binding/redaction entirely
|
196
197
|
debug_on = log.isEnabledFor(logging.DEBUG)
|
197
198
|
if debug_on:
|
198
|
-
# Build a minimal, sanitized args snapshot
|
199
199
|
snapshot: dict[str, Any] = {}
|
200
|
-
# Map positional args to param names without inspect overhead by relying on kwargs only:
|
201
|
-
# we assume call sites are using kwargs in the wrapper (they do).
|
202
200
|
for k in include:
|
203
201
|
val = kwargs.get(k, None)
|
204
202
|
if k in transforms:
|
@@ -209,7 +207,6 @@ def log_call(
|
|
209
207
|
else:
|
210
208
|
val = redact_param(k, val)
|
211
209
|
snapshot[k] = val
|
212
|
-
|
213
210
|
start = perf_counter()
|
214
211
|
log.debug(
|
215
212
|
"→ %s(%s)",
|
@@ -219,21 +216,18 @@ def log_call(
|
|
219
216
|
)
|
220
217
|
|
221
218
|
try:
|
222
|
-
result = await fn(
|
219
|
+
result = await fn(*args, **kwargs)
|
223
220
|
if debug_on:
|
224
221
|
dur_ms = (perf_counter() - start) * 1000.0
|
225
|
-
# Keep result logging ultra-light
|
226
|
-
result_type = type(result).__name__
|
227
222
|
log.debug(
|
228
223
|
"← %s ok in %.1f ms (%s)",
|
229
224
|
op,
|
230
225
|
dur_ms,
|
231
|
-
|
226
|
+
type(result).__name__,
|
232
227
|
extra={"operation": op},
|
233
228
|
)
|
234
229
|
return result
|
235
230
|
except Exception as e:
|
236
|
-
# WARNING with sanitized error; no param dump on failures
|
237
231
|
log.warning(
|
238
232
|
"%s failed: %s", op, e.__class__.__name__, extra={"operation": op}
|
239
233
|
)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
bookalimo/__init__.py,sha256=rzbMBdkp0hIIQJ8AVLHeA6y4YrNIezfzUxP2iNcRBaw,691
|
2
2
|
bookalimo/_client.py,sha256=-kpaWBeEwFcXL28he0zFpx557jcZTUcx_NTjraSHSPQ,14537
|
3
|
-
bookalimo/_logging.py,sha256=
|
3
|
+
bookalimo/_logging.py,sha256=xXpdUZ33vdIrbIReLTwWOIrGtxhvYcI1thV9rJ29Lsk,7120
|
4
4
|
bookalimo/exceptions.py,sha256=ubOUZiXGEOWZvXyz2D5f5zwxBlQZVDBv1uOPmokAQ6Q,404
|
5
5
|
bookalimo/models.py,sha256=-gvxrT7llrYLxSHWn3vpmvkQqnk2ejSd97Sw8BxgBLw,16420
|
6
6
|
bookalimo/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
7
7
|
bookalimo/wrapper.py,sha256=tusu2D4CkQqI7VKxSh62bK9hvleNHjuGD_6EpsWi2xg,13381
|
8
|
-
bookalimo-0.1.
|
9
|
-
bookalimo-0.1.
|
10
|
-
bookalimo-0.1.
|
11
|
-
bookalimo-0.1.
|
12
|
-
bookalimo-0.1.
|
8
|
+
bookalimo-0.1.5.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
bookalimo-0.1.5.dist-info/METADATA,sha256=I13Y5Ac15h6uXcDi4KvVEncHHEej4Dkyt390EXuwooY,10739
|
10
|
+
bookalimo-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
bookalimo-0.1.5.dist-info/top_level.txt,sha256=ZgYiDX2GfZCp4pevWn4X2qyEr-Dh7-cq5Y1j2jMhB1s,10
|
12
|
+
bookalimo-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|