Skip to content

Commit

Permalink
chore: Bump version to 0.2.0 (#6)
Browse files Browse the repository at this point in the history
* fix: Pin pyyaml version

* fix: Fix error when parsing exception data

* chore: Bump lib version to 0.2.0
  • Loading branch information
rai200890 authored Jan 9, 2019
1 parent fdd5189 commit ce38ee9
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 88 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ yapf = "~=0.24.0"
ipdb = "~=0.11"
safety = "~=1.8.4"
twine = "~=1.12.1"
pyyaml = ">=4.2b4"

[requires]
python_version = "3.7"
154 changes: 74 additions & 80 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions google_cloud_logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ def __init__(self, *args, **kwargs):
def _get_extra_fields(self, record):
if hasattr(record, "extra"):
return record.extra
fields = set(
field for field in record.__dict__.keys() if not inspect.ismethod(field)
).difference(set(self.reserved_attrs.keys()))
attributes = (field for field in record.__dict__.keys()
if not inspect.ismethod(field))

fields = set(attributes).difference(set(self.reserved_attrs.keys()))
return {key: getattr(record, key) for key in fields if key}

def add_fields(self, log_record, record, _message_dict):
Expand All @@ -46,7 +47,8 @@ def make_entry(self, record):
}

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

def format_severity(self, level_name):
levels = {
Expand All @@ -70,7 +72,7 @@ def make_exception(self, record):
}

def make_metadata(self, record):
if record.exc_info:
if hasattr(record, "exc_info"):
return {
"userLabels": self.make_user_labels(record),
"exception": self.make_exception(record),
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = output.read()


__VERSION__ = "0.1.1"
__VERSION__ = "0.2.0"

setup(
name="google_cloud_logger",
Expand All @@ -19,7 +19,7 @@
packages=find_packages(),
python_requires=">=3.4.*",
install_requires=[
"python-json-logger>=0.1.10",
"python-json-logger>=0.1.10"
],
classifiers=[
"Environment :: Web Environment",
Expand Down
4 changes: 3 additions & 1 deletion test/google_cloud_logger/test_google_cloud_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def test_make_metadata(formatter, record):
assert metadata["userLabels"]["extra_field"] == "extra"


def test_make_metadata_with_extra_attribute(formatter, record_with_extra_attribute):
def test_make_metadata_with_extra_attribute(
formatter,
record_with_extra_attribute):
metadata = formatter.make_metadata(record_with_extra_attribute)

assert metadata["userLabels"]["extra_field"] == "extra"
Expand Down

0 comments on commit ce38ee9

Please sign in to comment.