Skip to content

Commit f284c95

Browse files
committed
Version 3.1.0
* Drop logwrap function. Use class as-is. `logwrap = LogWrap` (No API changes).
1 parent 2a96285 commit f284c95

File tree

7 files changed

+8
-187
lines changed

7 files changed

+8
-187
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
CHANGELOG
22
=========
3+
Version 3.1.0
4+
-------------
5+
* Drop logwrap function. Use class as-is. `logwrap = LogWrap` (No API changes).
6+
37
Version 3.0.2
48
-------------
59
* Fix package README.

README.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Pros:
4848

4949
This package includes helpers:
5050

51-
* `logwrap` - main helper
51+
* `logwrap` - main helper. The same is `LogWrap`.
5252

5353
* `LogWrap` - class with `logwrap` implementation. May be used directly.
5454

@@ -168,8 +168,6 @@ Limitations:
168168

169169
LogWrap
170170
-------
171-
May be used as `logwrap` with possibility to read and change several parameters later.
172-
173171
Example construction and read from test:
174172

175173
.. code-block:: python

doc/source/logwrap.rst

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -69,52 +69,3 @@ API: Decorators: `LogWrap` class and `logwrap` function.
6969

7070
:returns: Decorated function. On python 3.3+ awaitable is supported.
7171
:rtype: typing.Union[typing.Callable, typing.Awaitable]
72-
73-
74-
.. py:function:: logwrap(log=logging.getLogger('logwrap'), log_level=logging.DEBUG, exc_level=logging.ERROR, max_indent=20, spec=None, blacklisted_names=None, blacklisted_exceptions=None, log_call_args=True, log_call_args_on_exc=True, log_result_obj=True, )
75-
76-
:param log: logger object for decorator, by default used 'logwrap'
77-
:type log: typing.Union[logging.Logger, typing.Callable]
78-
:param log_level: log level for successful calls
79-
:type log_level: int
80-
:param exc_level: log level for exception cases
81-
:type exc_level: int
82-
:param max_indent: maximum indent before classic `repr()` call.
83-
:type max_indent: int
84-
:param spec: callable object used as spec for arguments bind.
85-
This is designed for the special cases only,
86-
when impossible to change signature of target object,
87-
but processed/redirected signature is accessible.
88-
Note: this object should provide fully compatible
89-
signature with decorated function, or arguments bind
90-
will be failed!
91-
:type spec: typing.Optional[typing.Callable]
92-
:param blacklisted_names: Blacklisted argument names.
93-
Arguments with this names will be skipped in log.
94-
95-
.. versionadded:: 1.3.0
96-
:type blacklisted_names: typing.Optional[typing.Iterable[str]]
97-
:param blacklisted_exceptions: list of exception,
98-
which should be re-raised without
99-
producing log record.
100-
101-
.. versionadded:: 2.2.0
102-
:type blacklisted_exceptions: typing.Optional[typing.Iterable[Exception]]
103-
:param log_call_args: log call arguments before executing wrapped function.
104-
105-
.. versionadded:: 2.2.0
106-
:type log_call_args: bool
107-
:param log_call_args_on_exc: log call arguments if exception raised.
108-
109-
.. versionadded:: 2.2.0
110-
:type log_call_args_on_exc: bool
111-
112-
:param log_result_obj: log result of function call.
113-
114-
.. versionadded:: 2.2.0
115-
:type log_result_obj: bool
116-
117-
:returns: LogWrap decorator instance
118-
:rtype: LogWrap
119-
120-
.. versionchanged:: 2.2.0

logwrap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'pretty_str'
5454
)
5555

56-
__version__ = '3.0.2'
56+
__version__ = '3.1.0'
5757
__author__ = "Alexey Stepanov"
5858
__author_email__ = 'penguinolog@gmail.com'
5959
__url__ = 'https://github.com/penguinolog/logwrap'

logwrap/_log_wrap2.py

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
from __future__ import absolute_import
2424
from __future__ import unicode_literals
2525

26-
import logging
27-
2826
import six
2927
# noinspection PyUnresolvedReferences
3028
import funcsigs
@@ -74,63 +72,4 @@ def wrapper(*args, **kwargs):
7472
return wrapper
7573

7674

77-
# pylint: disable=unexpected-keyword-arg, no-value-for-parameter
78-
def logwrap(
79-
log=_log_wrap_shared.logger,
80-
log_level=logging.DEBUG,
81-
exc_level=logging.ERROR,
82-
max_indent=20,
83-
spec=None,
84-
blacklisted_names=None,
85-
blacklisted_exceptions=None,
86-
log_call_args=True,
87-
log_call_args_on_exc=True,
88-
log_result_obj=True,
89-
):
90-
"""Log function calls and return values.
91-
92-
:param log: logger object for decorator, by default used 'logwrap'
93-
:type log: typing.Union[logging.Logger, typing.Callable]
94-
:param log_level: log level for successful calls
95-
:type log_level: int
96-
:param exc_level: log level for exception cases
97-
:type exc_level: int
98-
:param max_indent: maximum indent before classic `repr()` call.
99-
:type max_indent: int
100-
:param spec: callable object used as spec for arguments bind.
101-
This is designed for the special cases only,
102-
when impossible to change signature of target object,
103-
but processed/redirected signature is accessible.
104-
Note: this object should provide fully compatible signature
105-
with decorated function, or arguments bind will be failed!
106-
:type spec: typing.Optional[typing.Callable]
107-
:param blacklisted_names: list of exception,
108-
which should be re-raised without
109-
producing log record.
110-
:type blacklisted_names: typing.Optional[typing.Iterable[str]]
111-
:param blacklisted_exceptions: list of exception,
112-
which should be re-raised without
113-
producing log record.
114-
:type blacklisted_exceptions: typing.Optional[typing.Iterable[Exception]]
115-
:param log_call_args: log call arguments before executing wrapped function.
116-
:type log_call_args: bool
117-
:param log_call_args_on_exc: log call arguments if exception raised.
118-
:type log_call_args_on_exc: bool
119-
:param log_result_obj: log result of function call.
120-
:type log_result_obj: bool
121-
:return: built real decorator.
122-
:rtype: _log_wrap_shared.BaseLogWrap
123-
"""
124-
return LogWrap(
125-
log=log,
126-
log_level=log_level,
127-
exc_level=exc_level,
128-
max_indent=max_indent,
129-
spec=spec,
130-
blacklisted_names=blacklisted_names,
131-
blacklisted_exceptions=blacklisted_exceptions,
132-
log_call_args=log_call_args,
133-
log_call_args_on_exc=log_call_args_on_exc,
134-
log_result_obj=log_result_obj
135-
)
136-
# pylint: enable=unexpected-keyword-arg, no-value-for-parameter
75+
logwrap = LogWrap # lowercase decorator

logwrap/_log_wrap3.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import asyncio
2828
import functools
2929
import inspect
30-
import logging
3130
import typing
3231

3332

@@ -36,9 +35,6 @@
3635
__all__ = ('logwrap', 'LogWrap')
3736

3837

39-
DEFAULT_DECORATOR_ARGUMENT = typing.Union[logging.Logger, typing.Callable]
40-
41-
4238
class LogWrap(_log_wrap_shared.BaseLogWrap):
4339
"""Python 3.3+ version of LogWrap."""
4440

@@ -110,63 +106,4 @@ def wrapper(*args, **kwargs):
110106
return async_wrapper if asyncio.iscoroutinefunction(func) else wrapper
111107

112108

113-
# pylint: disable=unexpected-keyword-arg, no-value-for-parameter
114-
def logwrap(
115-
log: DEFAULT_DECORATOR_ARGUMENT = _log_wrap_shared.logger,
116-
log_level: int = logging.DEBUG,
117-
exc_level: int = logging.ERROR,
118-
max_indent: int = 20,
119-
spec: typing.Optional[typing.Callable] = None,
120-
blacklisted_names: typing.Optional[typing.List[str]] = None,
121-
blacklisted_exceptions: typing.Optional[typing.List[Exception]] = None,
122-
log_call_args: bool = True,
123-
log_call_args_on_exc: bool = True,
124-
log_result_obj: bool = True,
125-
) -> LogWrap:
126-
"""Log function calls and return values. Python 3.4+ version.
127-
128-
:param log: logger object for decorator, by default used 'logwrap'
129-
:type log: typing.Union[logging.Logger, typing.Callable]
130-
:param log_level: log level for successful calls
131-
:type log_level: int
132-
:param exc_level: log level for exception cases
133-
:type exc_level: int
134-
:param max_indent: maximum indent before classic `repr()` call.
135-
:type max_indent: int
136-
:param spec: callable object used as spec for arguments bind.
137-
This is designed for the special cases only,
138-
when impossible to change signature of target object,
139-
but processed/redirected signature is accessible.
140-
Note: this object should provide fully compatible signature
141-
with decorated function, or arguments bind will be failed!
142-
:type spec: typing.Optional[typing.Callable]
143-
:param blacklisted_names: list of exception,
144-
which should be re-raised without
145-
producing log record.
146-
:type blacklisted_names: typing.Optional[typing.Iterable[str]]
147-
:param blacklisted_exceptions: list of exception,
148-
which should be re-raised without
149-
producing log record.
150-
:type blacklisted_exceptions: typing.Optional[typing.Iterable[Exception]]
151-
:param log_call_args: log call arguments before executing wrapped function.
152-
:type log_call_args: bool
153-
:param log_call_args_on_exc: log call arguments if exception raised.
154-
:type log_call_args_on_exc: bool
155-
:param log_result_obj: log result of function call.
156-
:type log_result_obj: bool
157-
:return: built real decorator.
158-
:rtype: _log_wrap_shared.BaseLogWrap
159-
"""
160-
return LogWrap(
161-
log=log,
162-
log_level=log_level,
163-
exc_level=exc_level,
164-
max_indent=max_indent,
165-
spec=spec,
166-
blacklisted_names=blacklisted_names,
167-
blacklisted_exceptions=blacklisted_exceptions,
168-
log_call_args=log_call_args,
169-
log_call_args_on_exc=log_call_args_on_exc,
170-
log_result_obj=log_result_obj
171-
)
172-
# pylint: enable=unexpected-keyword-arg, no-value-for-parameter
109+
logwrap = LogWrap # lowercase decorator

tox.ini

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ deps =
1919
pytest
2020
pytest-cov
2121
pytest-html
22-
pytest-catchlog
2322
pytest-sugar
2423
py{34,35,36}-nocov: Cython
2524
-r{toxinidir}/CI_REQUIREMENTS.txt
@@ -108,13 +107,6 @@ deps =
108107
sphinx
109108
commands = python setup.py build_sphinx
110109

111-
[testenv:upload_docs]
112-
deps =
113-
sphinx
114-
sphinx-pypi-upload
115-
-r{toxinidir}/CI_REQUIREMENTS.txt
116-
commands = python setup.py build_sphinx upload_sphinx
117-
118110
[testenv:bandit]
119111
deps = bandit
120112
commands = bandit -r logwrap

0 commit comments

Comments
 (0)