mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 13:44:58 -04:00
Annotate log_function
decorator (#10943)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
This commit is contained in:
parent
4e393af52f
commit
75ca0a6168
12 changed files with 58 additions and 18 deletions
|
@ -16,6 +16,7 @@
|
|||
import logging
|
||||
from functools import wraps
|
||||
from inspect import getcallargs
|
||||
from typing import Callable, TypeVar, cast
|
||||
|
||||
_TIME_FUNC_ID = 0
|
||||
|
||||
|
@ -41,7 +42,10 @@ def _log_debug_as_f(f, msg, msg_args):
|
|||
logger.handle(record)
|
||||
|
||||
|
||||
def log_function(f):
|
||||
F = TypeVar("F", bound=Callable)
|
||||
|
||||
|
||||
def log_function(f: F) -> F:
|
||||
"""Function decorator that logs every call to that function."""
|
||||
func_name = f.__name__
|
||||
|
||||
|
@ -69,4 +73,4 @@ def log_function(f):
|
|||
return f(*args, **kwargs)
|
||||
|
||||
wrapped.__name__ = func_name
|
||||
return wrapped
|
||||
return cast(F, wrapped)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue