Release 1.2.2

This commit is contained in:
Wojciech Kozlowski 2017-03-14 22:32:19 +00:00
parent 4c8bfc2763
commit 6395ddd821
3 changed files with 48 additions and 42 deletions

View File

@ -1,6 +1,11 @@
Changelog Changelog
========= =========
1.2.2
-----
- Modified message wrapping code.
1.2.1 1.2.1
----- -----

View File

@ -478,54 +478,55 @@ def trace(message, function=None):
# ----------------------------------------------------------------- # -----------------------------------------------------------------
wrapped = textwrap.wrap(message, MESSAGE_WIDTH) wrapped = textwrap.wrap(message, MESSAGE_WIDTH)
if wrapped: if not wrapped:
if MESSAGE_WRAP: wrapped = [""]
# --------------------------------------------------------- if MESSAGE_WRAP:
# Print the first line. It gets special treatment
# as it doesn't need whitespace in front of it.
# ---------------------------------------------------------
msg += wrapped[0]
# -------------------------------------------------------------
# Print the first line. It gets special treatment as
# it doesn't need whitespace in front of it.
# -------------------------------------------------------------
msg += wrapped[0]
# -------------------------------------------------------------
# Print the remaining lines. Append whitespace to
# align it with the first line.
# -------------------------------------------------------------
for line in wrapped[1:]:
msg += '\n' + '{:{w}}'.format('', w=premsglen) + line
else:
# -------------------------------------------------------------
# The message is not being wrapped.
# -------------------------------------------------------------
if MESSAGE_MARK_TRUNCATION and wrapped[1:]:
# --------------------------------------------------------- # ---------------------------------------------------------
# Print the remaining lines. Append whitespace to # We want to mark truncated lines so we need to
# align it with the first line. # determine if the line is being truncated. If it
# is we replace the last character with '\'.
# --------------------------------------------------------- # ---------------------------------------------------------
for line in wrapped[1:]:
msg += '\n' + '{:{w}}'.format('', w=premsglen) + line if MESSAGE_WIDTH > 1:
wrapped = textwrap.wrap(wrapped[0],
MESSAGE_WIDTH - 1)
assert wrapped
msg += ('{m:{w}}'.format(m=wrapped[0],
w=MESSAGE_WIDTH - 1) +
'\\')
else:
assert MESSAGE_WIDTH == 1
msg += '\\'
else: else:
# --------------------------------------------------------- # ---------------------------------------------------------
# The message is not being wrapped. # Either the message is not being truncated or
# MESSAGE_MARK_TRUNCATION is False.
# --------------------------------------------------------- # ---------------------------------------------------------
msg += wrapped[0]
if MESSAGE_MARK_TRUNCATION and wrapped[1:]:
# -----------------------------------------------------
# We want to mark truncated lines so we need
# to determine if the line is being
# truncated. If it is we replace the last
# character with '\'.
# -----------------------------------------------------
if MESSAGE_WIDTH > 1:
wrapped = textwrap.wrap(wrapped[0],
MESSAGE_WIDTH - 1)
assert wrapped
msg += ('{m:{w}}'.format(m=wrapped[0],
w=MESSAGE_WIDTH - 1) +
'\\')
else:
assert MESSAGE_WIDTH == 1
msg += '\\'
else:
# -----------------------------------------------------
# Either the message is not being truncated or
# MESSAGE_MARK_TRUNCATION is False.
# -----------------------------------------------------
msg += wrapped[0]
else: else:
# ----------------------------------------------------------------- # -----------------------------------------------------------------

View File

@ -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.1', version='1.2.2',
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',
@ -17,7 +17,7 @@ setup(
author='Wojciech Kozlowski', author='Wojciech Kozlowski',
author_email='wojciech.kozlowski@vivaldi.net', author_email='wojciech.kozlowski@vivaldi.net',
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', 'Development Status :: 4 - Beta',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'Topic :: Software Development :: Debuggers', 'Topic :: Software Development :: Debuggers',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',