Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion logwrap/__init__.pxd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cdef tuple __all__
cpdef tuple __all__
5 changes: 2 additions & 3 deletions logwrap/__init__.pyx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from .repr_utils cimport PrettyFormat, PrettyRepr, PrettyStr
from .repr_utils import pretty_repr, pretty_str
from .repr_utils cimport PrettyFormat, PrettyRepr, PrettyStr, pretty_repr, pretty_str

from .log_wrap cimport LogWrap
from .log_wrap import logwrap, BoundParameter, bind_args_kwargs

cdef tuple __all__ = (
cpdef tuple __all__ = (
"LogWrap",
"logwrap",
"PrettyFormat",
Expand Down
5 changes: 3 additions & 2 deletions logwrap/class_decorator.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@


cdef class BaseDecorator:
cdef readonly object _func
cdef dict __dict__
cdef:
readonly object _func
dict __dict__
4 changes: 1 addition & 3 deletions logwrap/class_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class BaseDecorator(metaclass=abc.ABCMeta):

Implements wrapping and __call__, wrapper getter is abstract.

Note:
wrapper getter is called only on function call,
if decorator used without braces.
.. note:: wrapper getter is called only on function call, if decorator used without braces.

Usage example:

Expand Down
20 changes: 17 additions & 3 deletions logwrap/class_decorator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ import typing


cdef class BaseDecorator:
"""Base class for decorators."""
"""Base class for decorators.

Implements wrapping and __call__, wrapper getter is abstract.

.. note:: wrapper getter is called only on function call, if decorator used without braces.
"""

def __init__(self, func: typing.Optional[typing.Callable] = None) -> None:
"""Decorator."""
"""Decorator.

:param func: function to wrap
:type func: typing.Optional[typing.Callable]
"""
# noinspection PyArgumentList
super(BaseDecorator, self).__init__()
# pylint: disable=assigning-non-slot
Expand All @@ -32,7 +41,12 @@ cdef class BaseDecorator:
# pylint: enable=assigning-non-slot

def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable:
"""Here should be constructed and returned real decorator."""
"""Here should be constructed and returned real decorator.

:param func: Wrapped function
:type func: typing.Callable
:rtype: typing.Callable
"""
raise NotImplementedError() # pragma: no cover

def __call__(self, *args: typing.Union[typing.Callable, typing.Any], **kwargs: typing.Any) -> typing.Any:
Expand Down
50 changes: 23 additions & 27 deletions logwrap/log_wrap.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,34 @@ import typing
from logwrap cimport class_decorator


cdef unsigned int indent
cdef:
unsigned int indent


cdef str pretty_repr(
src: typing.Any,
unsigned int indent=?,
bint no_indent_start=?,
unsigned int max_indent=?,
unsigned int indent_step=?
)
class LogWrap(class_decorator.BaseDecorator):
"""Base class for LogWrap implementation."""

cdef:
public unsigned int log_level
public unsigned int exc_level
public unsigned int max_indent

cdef class LogWrap(class_decorator.BaseDecorator):
"""Base class for LogWrap implementation."""
public bint log_call_args
public bint log_call_args_on_exc
public bint log_traceback
public bint log_result_obj

cdef public unsigned int log_level
cdef public unsigned int exc_level
cdef public unsigned int max_indent
readonly object _spec
readonly object _logger

cdef public bint log_call_args
cdef public bint log_call_args_on_exc
cdef public bint log_traceback
cdef public bint log_result_obj
list __blacklisted_names
list __blacklisted_exceptions

cdef list __blacklisted_names
cdef list __blacklisted_exceptions
cdef object __logger
cdef object __spec
cpdef object pre_process_param(self, object arg)
cpdef str post_process_param(self, object arg, str arg_repr)

cdef str _get_func_args_repr(
self, sig: inspect.Signature, args: typing.Tuple, kwargs: typing.Dict[str, typing.Any]
)
cdef void _make_done_record(self, str func_name, result: typing.Any)
cdef void _make_calling_record(self, str name, str arguments, str method=?)
cdef void _make_exc_record(self, str name, str arguments)
cdef:
str _get_func_args_repr(self, sig: inspect.Signature, tuple args, dict kwargs)
void _make_done_record(self, str func_name, result: typing.Any)
void _make_calling_record(self, str name, str arguments, str method=?)
void _make_exc_record(self, str name, str arguments)
2 changes: 1 addition & 1 deletion logwrap/log_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def logwrap( # noqa: F811 # pylint: disable=unexpected-keyword-arg, no-value-f
log_traceback: bool = True,
log_result_obj: bool = True
) -> typing.Union[LogWrap, typing.Callable]:
"""Log function calls and return values. Python 3.4+ version.
"""Log function calls and return values.

:param func: function to wrap
:type func: typing.Optional[typing.Callable]
Expand Down
Loading