Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
build
dist
*.egg-info

# Tests and validation
.tox/
.mypy_cache

# Python's venv
.env
.venv
env

# IDE
.vscode
.idea
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
python-tag=py3

[mypy]

# For details on each flag, please see the mypy documentation at:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package_dir={'': 'src'},
packages=find_packages("src", exclude="tests"),
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
python_requires='>=3.5',
python_requires='>=3.7',
test_suite="tests.tests",
classifiers=[
'Development Status :: 6 - Mature',
Expand Down
13 changes: 4 additions & 9 deletions src/pythonjsonlogger/jsonlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,10 @@ def format(self, record: logging.LogRecord) -> str:
message_dict['exc_info'] = record.exc_text
# Display formatted record of stack frames
# default format is a string returned from :func:`traceback.print_stack`
try:
if record.stack_info and not message_dict.get('stack_info'):
message_dict['stack_info'] = self.formatStack(record.stack_info)
except AttributeError:
# Python2.7 doesn't have stack_info.
pass

log_record: Dict[str, Any]
log_record = OrderedDict()
if record.stack_info and not message_dict.get('stack_info'):
message_dict['stack_info'] = self.formatStack(record.stack_info)

log_record: Dict[str, Any] = OrderedDict()
self.add_fields(log_record, record, message_dict)
log_record = self.process_log_record(log_record)

Expand Down
8 changes: 2 additions & 6 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
except ImportError:
pass

try:
from StringIO import StringIO # noqa
except ImportError:
# Python 3 Support
from io import StringIO
from io import StringIO

sys.path.append('src/python-json-logger')
from pythonjsonlogger import jsonlogger
Expand Down Expand Up @@ -78,7 +74,6 @@ def testAddStaticFields(self):
self.assertEqual(logJson["log_stream"], "kafka")
self.assertEqual(logJson["message"], msg)


def testFormatKeys(self):
supported_keys = [
'asctime',
Expand Down Expand Up @@ -258,6 +253,7 @@ def encode_complex(z):
msg = self.buffer.getvalue()
self.assertEqual(msg, "{\"message\": \" message\", \"special\": [3.0, 8.0]}\n")


if __name__ == '__main__':
if len(sys.argv[1:]) > 0:
if sys.argv[1] == 'xml':
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[tox]
envlist = pypy38, py36, py37, py38, py39, py310
envlist = pypy38, py37, py38, py39, py310

[gh-actions]
python =
pypy-3.8: pypy38
3.6: py36
3.7: py37
3.8: py38
3.9: py39
Expand Down