Skip to content

Commit

Permalink
Changed timestamp type from 'str' to 'datetime.datetime'. Convert the…
Browse files Browse the repository at this point in the history
… timestamp to a RFC3339 string representation in the helper function _make_entry_resource.
  • Loading branch information
francois kawala committed Dec 14, 2016
1 parent f52288a commit 7ac9c0a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions logging/google/cloud/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json

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


class Logger(object):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

This comment has been minimized.

Copy link
@sactre

return resource

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 7ac9c0a

Please sign in to comment.