Skip to content

Commit

Permalink
chore: Bump version to 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rai200890 committed Jan 9, 2019
1 parent b37997c commit 8431da9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
5 changes: 2 additions & 3 deletions google_cloud_logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def __init__(self, *args, **kwargs):
def _get_extra_fields(self, record):
if hasattr(record, "extra"):
return record.extra
attributes = (
field for field in record.__dict__.keys() if not inspect.ismethod(field)
)
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}
Expand Down
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
with open("README.md", "r") as output:
long_description = output.read()


__VERSION__ = "0.2.0"
__VERSION__ = "0.2.1"

setup(
name="google_cloud_logger",
Expand All @@ -18,15 +17,11 @@
license="MIT",
packages=find_packages(),
python_requires=">=3.4.*",
install_requires=[
"python-json-logger>=0.1.10"
],
install_requires=["python-json-logger>=0.1.10"],
classifiers=[
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Environment :: Web Environment", "Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Natural Language :: English", "Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Topic :: System :: Logging"
],
Expand Down
46 changes: 27 additions & 19 deletions test/google_cloud_logger/test_google_cloud_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from google_cloud_logger import GoogleCloudFormatter


# from https://stackoverflow.com/a/19258720
class FakeCode(object):
def __init__(self, co_filename, co_name):
Expand Down Expand Up @@ -64,7 +65,9 @@ def record_with_extra_attribute(log_record_factory, mocker):
"lineno": "88",
"levelname": "WARNING",
"message": "farofa",
"extra": {"extra_field": "extra"},
"extra": {
"extra_field": "extra"
},
}
record = log_record_factory(**data)
record.getMessage = mocker.Mock(return_value=data["message"])
Expand Down Expand Up @@ -95,19 +98,25 @@ def test_add_fields(formatter, record, mocker):
mocker.patch.object(
formatter,
"make_entry",
return_value=OrderedDict(
[
("timestamp", "2018-08-30 20:40:57Z"),
("severity", "WARNING"),
("message", "farofa"),
("labels", {"type": "python-application"}),
("metadata", {"userLabels": {}}),
(
"sourceLocation",
{"file": "_internal.py", "function": "_log", "line": "88"},
),
]
),
return_value=OrderedDict([
("timestamp", "2018-08-30 20:40:57Z"),
("severity", "WARNING"),
("message", "farofa"),
("labels", {
"type": "python-application"
}),
("metadata", {
"userLabels": {}
}),
(
"sourceLocation",
{
"file": "_internal.py",
"function": "_log",
"line": "88"
},
),
]),
)
formatter.add_fields(log_record, record, {})

Expand Down Expand Up @@ -141,7 +150,8 @@ 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 All @@ -166,10 +176,8 @@ def test_make_source_location(formatter, record):


def test_format_timestamp(formatter):
assert (
formatter.format_timestamp("2018-08-30 20:40:57,245")
== "2018-08-30T20:40:57.245000Z"
)
assert (formatter.format_timestamp("2018-08-30 20:40:57,245") ==
"2018-08-30T20:40:57.245000Z")


@pytest.mark.parametrize(
Expand Down

0 comments on commit 8431da9

Please sign in to comment.