Skip to content

Commit b945006

Browse files
authored
Logging: add support for additional 'LogEntry' fields (#6229)
Use namedtuples to reduce boilerplate in 'logger.Batch', 'logger.Logger', and 'entries' implementations: remove 'entry_type' and 'PAYLOAD_KEY' warts, dispatching instead based on class to load / save payload. Parse 'LogEntry.receiveTimestamp' -> 'received_timestamp' attr. Make 'received_timestamp' default to 'None' for all instances. It is set only when parsing a server response. Add support for 'LogEntry.traceSampled' field. Add support for 'source_location' field of log entries. Add support for 'operation' field of log entries. Add 'ProtobufEntry.payload_json': Returns 'None' if the payload is a protobuf message. 'ProtobufEntry.payload_pb' now returns 'None' if the payload is *not* a protobuf message. Drop 'EmptyEntry': just use 'LogEntry'. Closes #5601. Closes #6094.
1 parent 4a8d52a commit b945006

File tree

8 files changed

+1272
-886
lines changed

8 files changed

+1272
-886
lines changed

docs/entries.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Entries
44
.. automodule:: google.cloud.logging.entries
55
:members:
66
:show-inheritance:
7+
:member-order: groupwise

google/cloud/logging/_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import requests
1818

19-
from google.cloud.logging.entries import EmptyEntry
19+
from google.cloud.logging.entries import LogEntry
2020
from google.cloud.logging.entries import ProtobufEntry
2121
from google.cloud.logging.entries import StructEntry
2222
from google.cloud.logging.entries import TextEntry
@@ -54,7 +54,7 @@ def entry_from_resource(resource, client, loggers):
5454
if 'protoPayload' in resource:
5555
return ProtobufEntry.from_api_repr(resource, client, loggers)
5656

57-
return EmptyEntry.from_api_repr(resource, client, loggers)
57+
return LogEntry.from_api_repr(resource, client, loggers)
5858

5959

6060
def retrieve_metadata_server(metadata_key):

0 commit comments

Comments
 (0)