Skip to content
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

Add a timestamp parameter to the logger. #2860

Merged
merged 4 commits into from
Dec 15, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Changed timestamp type from 'str' to 'datetime.datetime'. Convert the…
… timestamp to a RFC3339 string representation in the helper function _make_entry_resource.
francois kawala committed Dec 14, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7ac9c0a42a97348275c83210d395ea55429194a9
18 changes: 10 additions & 8 deletions logging/google/cloud/logging/logger.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import json

from google.protobuf.json_format import MessageToJson
from google.cloud._helpers import _datetime_to_rfc3339


class Logger(object):
@@ -120,7 +121,8 @@ def _make_entry_resource(self, text=None, info=None, message=None,
:type http_request: dict
:param http_request: (optional) info about HTTP request associated with
the entry
:type timestamp: str

:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.

:rtype: dict
@@ -158,7 +160,7 @@ def _make_entry_resource(self, text=None, info=None, message=None,
resource['httpRequest'] = http_request

if timestamp is not None:
resource['timestamp'] = timestamp
resource['timestamp'] = _datetime_to_rfc3339(timestamp)

return resource

@@ -190,7 +192,7 @@ def log_text(self, text, client=None, labels=None, insert_id=None,
:param http_request: (optional) info about HTTP request associated with
the entry

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
client = self._require_client(client)
@@ -227,7 +229,7 @@ def log_struct(self, info, client=None, labels=None, insert_id=None,
:param http_request: (optional) info about HTTP request associated with
the entry.

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
client = self._require_client(client)
@@ -264,7 +266,7 @@ def log_proto(self, message, client=None, labels=None, insert_id=None,
:param http_request: (optional) info about HTTP request associated with
the entry.

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
client = self._require_client(client)
@@ -373,7 +375,7 @@ def log_text(self, text, labels=None, insert_id=None, severity=None,
:param http_request: (optional) info about HTTP request associated with
the entry.

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
self.entries.append(
@@ -399,7 +401,7 @@ def log_struct(self, info, labels=None, insert_id=None, severity=None,
:param http_request: (optional) info about HTTP request associated with
the entry.

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
self.entries.append(
@@ -425,7 +427,7 @@ def log_proto(self, message, labels=None, insert_id=None, severity=None,
:param http_request: (optional) info about HTTP request associated with
the entry.

:type timestamp: str
:type timestamp: :class:`datetime.datetime`
:param timestamp: (optional) timestamp of event being logged.
"""
self.entries.append(