mirror of
https://github.com/Wojtek242/pylg.git
synced 2024-11-21 23:35:25 +01:00
Release 1.2.1
This commit is contained in:
parent
c29553985c
commit
4c8bfc2763
@ -1,6 +1,11 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
1.2.1
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Dummy implementation used when PyLg is disabled has been simplified.
|
||||||
|
|
||||||
1.2.0
|
1.2.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ template.
|
|||||||
- ``MESSAGE_WIDTH`` (default = ``0``) - the column width for the
|
- ``MESSAGE_WIDTH`` (default = ``0``) - the column width for the
|
||||||
message. A width of zero means unlimited.
|
message. A width of zero means unlimited.
|
||||||
|
|
||||||
- ``MESSAGE_WRAP`` (default = ``True``) - if ``True``, PyLG will wrap
|
- ``MESSAGE_WRAP`` (default = ``True``) - if ``True``, PyLg will wrap
|
||||||
the message to fit within the column width. Otherwise, the message
|
the message to fit within the column width. Otherwise, the message
|
||||||
will be truncated.
|
will be truncated.
|
||||||
|
|
||||||
|
@ -21,4 +21,4 @@ from .loadSettings import PYLG_ENABLE
|
|||||||
if PYLG_ENABLE:
|
if PYLG_ENABLE:
|
||||||
from .pylg import TraceFunction, trace
|
from .pylg import TraceFunction, trace
|
||||||
else:
|
else:
|
||||||
from .dummy import TraceFunction, trace
|
from .dummy import TraceFunctionDummy as TraceFunction, trace
|
||||||
|
@ -17,57 +17,25 @@
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from .pylg import TraceFunction
|
||||||
|
|
||||||
|
|
||||||
class TraceFunction(object):
|
class TraceFunctionDummy(TraceFunction):
|
||||||
|
|
||||||
""" Dummy implementation of TraceFunction.
|
""" Dummy implementation of TraceFunction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __get__(self, obj, objtype):
|
|
||||||
|
|
||||||
""" Support for instance functions.
|
|
||||||
"""
|
|
||||||
|
|
||||||
return partial(self.__call__, obj)
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
""" Constructor for dummy TraceFunction. Note that the behaviour is
|
""" Constructor for dummy TraceFunction.
|
||||||
different depending on whether TraceFunction is passed any
|
|
||||||
parameters. For details see the non-dummy implementation.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
# Make sure this decorator is never called with no arguments.
|
# Rather than having an entirely empty dummy class, we call
|
||||||
|
# the superclass constructor to have input verification even
|
||||||
|
# when PyLg is disabled.
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
assert args or kwargs
|
super(TraceFunctionDummy, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
if args:
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
# The function init_function will verify the input.
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
self.init_function(*args, **kwargs)
|
|
||||||
|
|
||||||
if kwargs:
|
|
||||||
|
|
||||||
trace_args_str = 'trace_args'
|
|
||||||
trace_rv_str = 'trace_rv'
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
# If kwargs is non-empty, it should only contain trace_rv,
|
|
||||||
# trace_args, or both and args should be empty. Assert all
|
|
||||||
# this.
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
assert not args
|
|
||||||
assert (len(kwargs) > 0) and (len(kwargs) <= 2)
|
|
||||||
if len(kwargs) == 1:
|
|
||||||
assert (trace_rv_str in kwargs) or (trace_args_str in kwargs)
|
|
||||||
elif len(kwargs) == 2:
|
|
||||||
assert (trace_rv_str in kwargs) and (trace_args_str in kwargs)
|
|
||||||
|
|
||||||
self.function = None
|
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ class TraceFunction(object):
|
|||||||
value = kwargs[name]
|
value = kwargs[name]
|
||||||
else:
|
else:
|
||||||
value = self.function.defaults[name]
|
value = self.function.defaults[name]
|
||||||
msg += self.get_value_string(value) + ", "
|
msg += self.get_value_string(value) + ", "
|
||||||
|
|
||||||
msg = msg[:-2]
|
msg = msg[:-2]
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ TRACE_MESSAGE = True
|
|||||||
MESSAGE_WIDTH = 0
|
MESSAGE_WIDTH = 0
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# If True, PyLG will wrap the message to fit within the column
|
# If True, PyLg will wrap the message to fit within the column
|
||||||
# width. Otherwise, the message will be truncated.
|
# width. Otherwise, the message will be truncated.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
MESSAGE_WRAP = True
|
MESSAGE_WRAP = True
|
||||||
|
2
setup.py
2
setup.py
@ -9,7 +9,7 @@ with open(path.join(pwd, 'README.rst'), encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='PyLg',
|
name='PyLg',
|
||||||
version='1.2.0',
|
version='1.2.1',
|
||||||
description='Python module to facilitate and automate the process of writing runtime logs.',
|
description='Python module to facilitate and automate the process of writing runtime logs.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://gitlab.wojciechkozlowski.eu/wojtek/PyLg',
|
url='https://gitlab.wojciechkozlowski.eu/wojtek/PyLg',
|
||||||
|
Loading…
Reference in New Issue
Block a user