@@ -19,15 +19,23 @@ logwrap
1919
2020
2121logwrap is a helper for logging in human-readable format function arguments and call result on function call.
22+ Why? Because logging of `*args, **kwargs ` become useless with project grow and you need more details in call log.
23+
24+ Cons:
25+
26+ * Log records are not single line.
2227
2328Pros:
2429
30+ * Log records are not single 100500 symbols length line.
31+ (Especially actual for testing/development environments and for Kibana users).
32+ * Service free: job is done by this library and it's dependencies. It works at virtualenv
2533* Free software: Apache license
2634* Open Source: https://github.com/penguinolog/logwrap
2735* PyPI packaged: https://pypi.python.org/pypi/logwrap
2836* Self-documented code: docstrings with types in comments
2937* Tested: see bages on top
30- * Support miltiple Python versions:
38+ * Support multiple Python versions:
3139
3240::
3341
@@ -38,15 +46,21 @@ Pros:
3846 PyPy
3947 Jyton 2.7
4048
41- This package also includes helpers:
49+ This package includes helpers:
50+
51+ * `logwrap ` - main helper
52+
53+ * `LogWrap ` - class with `logwrap ` implementation. May be used directly.
4254
4355* `pretty_repr `
4456
4557* `pretty_str `
4658
4759* `PrettyFormat `
4860
49- * `async_logwrap ` *on python 3.5+ only *
61+ * `async_logwrap ` (*on python 3.4+ only *)
62+
63+ * `AsyncLogWrap ` - class with `async_logwrap ` implementation. May be used directly. (*on python 3.4+ only *)
5064
5165Usage
5266=====
@@ -66,6 +80,10 @@ Argumented usage with arguments from signature:
6680 max_indent = 20 , # forwarded to the pretty_repr
6781 spec = None , # use target callable function for spec
6882 blacklisted_names = None , # list argument names, which should be dropped from log
83+ blacklisted_exceptions = None , # Exceptions to skip in log
84+ log_call_args = True , # Log call arguments before call
85+ log_call_args_on_exc = True , # Log call arguments if exception happens
86+ log_result_obj = True , # Log result object
6987 )
7088
7189 Usage examples:
@@ -88,7 +106,9 @@ Get decorator for use without parameters:
88106
89107.. code-block :: python
90108
91- get_logs = logwap.logwrap() # set required parameters via arguments
109+ get_logs = logwrap.logwrap() # set required parameters via arguments
110+
111+ type (get_logs) == LogWrap # All logic is implemented in LogWrap class starting from version 2.2.0
92112
93113 @get_logs
94114 def foo ():
@@ -151,10 +171,30 @@ Limitations:
151171
152172* nested wrapping (`@logwrap @deco2 ... `) is not parsed under python 2.7: `funcsigs ` limitation. Please set `logwrap ` as the first level decorator.
153173
174+ LogWrap
175+ -------
176+ May be used as `logwrap ` with possibility to read and change several parameters later.
177+
178+ Example construction and read from test:
179+
180+ .. code-block :: python
181+
182+ log_call = logwrap.LogWrap()
183+ log_call.log_level == logging.DEBUG
184+ log_call.exc_level == logging.ERROR
185+ log_call.max_indent == 20
186+ log_call.blacklisted_names == []
187+ log_call.blacklisted_exceptions == []
188+ log_call.log_call_args == True
189+ log_call.log_call_args_on_exc == True
190+ log_call.log_result_obj == True
191+
192+ On object change, variable types is validated.
193+
154194async_logwrap
155195-------------
156196Async version of `logwrap ` decorator. Usage is the same as `logwrap `, but result object type is coroutine.
157- **This method is available only on python 3.5 + installations. **
197+ **This method is available only on python 3.4 + installations. **
158198
159199Example:
160200
@@ -165,7 +205,7 @@ Example:
165205 import logwrap
166206
167207 @logwrap.async_logwrap
168- async def foo():
208+ async def foo(): # asynio.coroutine is supported without any adoptions.
169209 pass
170210
171211 asyncio.get_event_loop().run_until_complete(foo())
@@ -184,6 +224,10 @@ Remember: `async_logwrap` can be applied over classic functions, but anyway it w
184224
185225 asyncio.get_event_loop().run_until_complete(foo())
186226
227+ AsyncLogWrap
228+ ------------
229+ The same as `LogWrap `, but for async_logwrap.
230+
187231
188232pretty_repr
189233-----------
0 commit comments