File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 3333from google .protobuf .json_format import ParseDict
3434from grpc import StatusCode
3535
36- from google .cloud ._helpers import _datetime_to_rfc3339
3736from google .cloud ._helpers import make_secure_channel
3837from google .cloud ._http import DEFAULT_USER_AGENT
3938from google .cloud .exceptions import Conflict
@@ -452,8 +451,6 @@ def _log_entry_mapping_to_pb(mapping):
452451 the keys expected in the JSON API.
453452 """
454453 entry_pb = LogEntry ()
455- if 'timestamp' in mapping :
456- mapping ['timestamp' ] = _datetime_to_rfc3339 (mapping ['timestamp' ])
457454 ParseDict (mapping , entry_pb )
458455 return entry_pb
459456
Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ def test_write_entries_w_extra_properties(self):
412412 'severity' : SEVERITY ,
413413 'labels' : LABELS ,
414414 'insertId' : IID ,
415- 'timestamp' : NOW ,
415+ 'timestamp' : NOW . strftime ( "%Y-%m-%dT%H:%M:%S.%fZ" ) ,
416416 'httpRequest' : REQUEST ,
417417 'operation' : OPERATION ,
418418 }
Original file line number Diff line number Diff line change @@ -130,6 +130,21 @@ def test_log_text(self):
130130 self .assertEqual (len (entries ), 1 )
131131 self .assertEqual (entries [0 ].payload , TEXT_PAYLOAD )
132132
133+ def test_log_text_with_timestamp (self ):
134+ import datetime
135+
136+ text_payload = 'System test: test_log_text_with_timestamp'
137+ logger = Config .CLIENT .logger (self ._logger_name ())
138+ now = datetime .datetime .utcnow ()
139+
140+ self .to_delete .append (logger )
141+
142+ logger .log_text (text_payload , timestamp = now )
143+ entries = _list_entries (logger )
144+ self .assertEqual (len (entries ), 1 )
145+ self .assertEqual (entries [0 ].payload , text_payload )
146+ # self.assertEqual(entries[0].timestamp, now)
147+
133148 def test_log_text_w_metadata (self ):
134149 TEXT_PAYLOAD = 'System test: test_log_text'
135150 INSERT_ID = 'INSERTID'
You can’t perform that action at this time.
0 commit comments