-
-
Notifications
You must be signed in to change notification settings - Fork 59
Rework on #109 #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Rework on #109 #111
Changes from all commits
5e5374c
db7b742
4fa1d53
19ce2ad
becd3f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding=utf-8 | ||
import json | ||
import logging | ||
import sys | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
# coding=utf-8 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding=utf-8 | ||
import logging | ||
import sys | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
def is_fastapi_present(): | ||
# noinspection PyPep8,PyBroadException | ||
try: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding=utf-8 | ||
import logging | ||
|
||
import json_logging | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding=utf-8 | ||
import logging | ||
import sys | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# coding=utf-8 | ||
import logging | ||
import logging.config | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
if version_info_major == 3: | ||
long_description = open('README.rst', encoding="utf8").read() | ||
else: | ||
io_open = io.open('README.rst', encoding="utf8") | ||
io_open = open('README.rst', encoding="utf8") | ||
long_description = io_open.read() | ||
Comment on lines
7
to
11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this pull request drops support for Python 2 and targets Python 3.9+, this entire You can simplify this logic to directly read the file. Using a with open('README.rst', encoding="utf8") as f:
long_description = f.read() |
||
|
||
setup( | ||
|
@@ -18,7 +18,7 @@ | |
description="JSON Python Logging", | ||
long_description=long_description, | ||
author="Bob T.", | ||
keywords=["json", "elastic", "python", "python3", "python2", "logging", "logging-library", "json", "elasticsearch", | ||
keywords=["json", "elastic", "python", "python3", "logging", "logging-library", "json", "elasticsearch", | ||
"elk", "elk-stack", "logstash", "kibana"], | ||
platforms='any', | ||
url="https://github.com/thangbn/json-logging", | ||
|
@@ -28,7 +28,6 @@ | |
'License :: OSI Approved :: Apache Software License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 3', | ||
'Topic :: System :: Logging', | ||
'Framework :: Flask', | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,8 @@ | ||||||
"""Constants shared by multiple tests""" | ||||||
|
||||||
STANDARD_MSG_ATTRIBUTES = { | ||||||
import sys | ||||||
|
||||||
_msg_attrs = [ | ||||||
"written_at", | ||||||
"written_ts", | ||||||
"msg", | ||||||
|
@@ -11,4 +13,9 @@ | |||||
"module", | ||||||
"line_no", | ||||||
"correlation_id", | ||||||
} | ||||||
] | ||||||
|
||||||
if sys.version_info.major == 3 and sys.version_info.minor >= 12: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version check can be made more concise and idiomatic by comparing the
Suggested change
|
||||||
_msg_attrs.append("taskName") | ||||||
|
||||||
STANDARD_MSG_ATTRIBUTES = set(_msg_attrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making
_epoch
a timezone-awaredatetime
object is a good step towards modernizing the codebase. However, this change will cause aTypeError
at runtime. The functionepoch_nano_second
will now fail when called with a timezone-naivedatetime
object, as it's not possible to subtract a naive from an aware datetime.For example,
json_logging.formatters.BaseJSONFormatter._format_log_object
calls it with a naive datetime:To fix this, you need to ensure that all callers of
epoch_nano_second
pass a timezone-awaredatetime
object. The most direct fix would be to remove.replace(tzinfo=None)
informatters.py
, but that change is outside the scope of this diff. Please ensure all call sites are updated to prevent runtime failures.