Skip to content

Commit ce38ee9

Browse files
authored
chore: Bump version to 0.2.0 (#6)
* fix: Pin pyyaml version * fix: Fix error when parsing exception data * chore: Bump lib version to 0.2.0
1 parent fdd5189 commit ce38ee9

File tree

5 files changed

+87
-88
lines changed

5 files changed

+87
-88
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ yapf = "~=0.24.0"
1515
ipdb = "~=0.11"
1616
safety = "~=1.8.4"
1717
twine = "~=1.12.1"
18+
pyyaml = ">=4.2b4"
1819

1920
[requires]
2021
python_version = "3.7"

Pipfile.lock

Lines changed: 74 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google_cloud_logger/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def __init__(self, *args, **kwargs):
1919
def _get_extra_fields(self, record):
2020
if hasattr(record, "extra"):
2121
return record.extra
22-
fields = set(
23-
field for field in record.__dict__.keys() if not inspect.ismethod(field)
24-
).difference(set(self.reserved_attrs.keys()))
22+
attributes = (field for field in record.__dict__.keys()
23+
if not inspect.ismethod(field))
24+
25+
fields = set(attributes).difference(set(self.reserved_attrs.keys()))
2526
return {key: getattr(record, key) for key in fields if key}
2627

2728
def add_fields(self, log_record, record, _message_dict):
@@ -46,7 +47,8 @@ def make_entry(self, record):
4647
}
4748

4849
def format_timestamp(self, asctime):
49-
return datetime.strptime(asctime, "%Y-%m-%d %H:%M:%S,%f").isoformat("T") + "Z"
50+
datetime_format = "%Y-%m-%d %H:%M:%S,%f"
51+
return datetime.strptime(asctime, datetime_format).isoformat("T") + "Z"
5052

5153
def format_severity(self, level_name):
5254
levels = {
@@ -70,7 +72,7 @@ def make_exception(self, record):
7072
}
7173

7274
def make_metadata(self, record):
73-
if record.exc_info:
75+
if hasattr(record, "exc_info"):
7476
return {
7577
"userLabels": self.make_user_labels(record),
7678
"exception": self.make_exception(record),

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
long_description = output.read()
55

66

7-
__VERSION__ = "0.1.1"
7+
__VERSION__ = "0.2.0"
88

99
setup(
1010
name="google_cloud_logger",
@@ -19,7 +19,7 @@
1919
packages=find_packages(),
2020
python_requires=">=3.4.*",
2121
install_requires=[
22-
"python-json-logger>=0.1.10",
22+
"python-json-logger>=0.1.10"
2323
],
2424
classifiers=[
2525
"Environment :: Web Environment",

test/google_cloud_logger/test_google_cloud_formatter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def test_make_metadata(formatter, record):
9696
assert metadata["userLabels"]["extra_field"] == "extra"
9797

9898

99-
def test_make_metadata_with_extra_attribute(formatter, record_with_extra_attribute):
99+
def test_make_metadata_with_extra_attribute(
100+
formatter,
101+
record_with_extra_attribute):
100102
metadata = formatter.make_metadata(record_with_extra_attribute)
101103

102104
assert metadata["userLabels"]["extra_field"] == "extra"

0 commit comments

Comments
 (0)