Skip to content

Commit

Permalink
fix: minor fix for debug_logging decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik committed Nov 26, 2024
1 parent 065c875 commit 67d9f22
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aidial_interceptors_sdk/utils/_debug.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import json
import logging
from typing import Awaitable, Callable, TypeVar
Expand All @@ -20,17 +21,18 @@ def debug_logging(
Callable[[_A], Awaitable[_B]],
]:
def decorator(
fn: Callable[[_A], Awaitable[_B]]
func: Callable[[_A], Awaitable[_B]]
) -> Callable[[_A], Awaitable[_B]]:
if not _debug():
return fn
return func

async def _fn(a: _A) -> _B:
@functools.wraps(func)
async def wrapper(a: _A) -> _B:
_log.debug(f"{title} old: {json.dumps(a)}")
b = await fn(a)
b = await func(a)
_log.debug(f"{title} new: {json.dumps(b)}")
return b

return _fn
return wrapper

return decorator

0 comments on commit 67d9f22

Please sign in to comment.