diff --git a/Makefile b/Makefile index 363ccaca7..6db805786 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ dist: .venv/timestamp .venv/bin/python setup.py bdist_wheel .PHONY: release -release: dist +release: acceptance dist .venv/bin/twine upload dist/*.whl run: build_test_app diff --git a/c2cwsgiutils/pyramid_logging.py b/c2cwsgiutils/pyramid_logging.py index 3b9270820..321af8d10 100644 --- a/c2cwsgiutils/pyramid_logging.py +++ b/c2cwsgiutils/pyramid_logging.py @@ -48,7 +48,7 @@ def _un_underscore(message): a lot of interesting fields with underscore. Therefore, it's a good idea to remove all those underscore prefixes. """ - for key, value in message.items(): + for key, value in list(message.items()): if key.startswith('_'): new_key = key[1:] if new_key not in message: @@ -57,11 +57,11 @@ def _un_underscore(message): return message -def new_make_message_dict(*args, **kargv): +def _make_message_dict(*args, **kargv): """ patch cee_syslog_handler to rename message->full_message otherwise this part is dropped by syslog. """ - msg = orig_make_message_dict(*args, **kargv) + msg = cee_syslog_handler.make_message_dict(*args, **kargv) if msg['message'] != msg['short_message']: # only output full_message if it's different from short message msg['full_message'] = msg['message'] @@ -69,10 +69,6 @@ def new_make_message_dict(*args, **kargv): return _un_underscore(msg) -orig_make_message_dict = cee_syslog_handler.make_message_dict -cee_syslog_handler.make_message_dict = new_make_message_dict - - class PyramidCeeSysLogHandler(cee_syslog_handler.CeeSysLogHandler): """ A CEE (JSON format) log handler with additional information about the current request. @@ -81,6 +77,11 @@ def __init__(self, *args): super().__init__(*args) self.addFilter(_PYRAMID_FILTER) + def format(self, record): + message = _make_message_dict(record, self._debugging_fields, self._extra_fields, False, None, + self._facility) + return ": @cee: %s" % json.dumps(message) + class JsonLogHandler(logging.StreamHandler): """ @@ -91,8 +92,8 @@ def __init__(self, stream=None): self.addFilter(_PYRAMID_FILTER) def format(self, record): - message = cee_syslog_handler.make_message_dict(record, debugging_fields=True, extra_fields=True, - fqdn=False, localname=None, facility=None) + message = _make_message_dict(record, debugging_fields=True, extra_fields=True, + fqdn=False, localname=None, facility=None) return json.dumps(message) diff --git a/setup.py b/setup.py index 36bc54a30..22a097fa6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -VERSION = '0.20.0' +VERSION = '0.20.1' HERE = os.path.abspath(os.path.dirname(__file__)) INSTALL_REQUIRES = open(os.path.join(HERE, 'requirements.txt')).read().splitlines()