Entries#

Log entries within the Google Stackdriver Logging API.

class google.cloud.logging.entries.ProtobufEntry(payload, logger, insert_id=None, timestamp=None, labels=None, severity=None, http_request=None, resource=None)[source]#

Bases: google.cloud.logging.entries._BaseEntry

Entry created with protoPayload.

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

Parameters:
  • payload (str, dict or any_pb2.Any) – The payload passed as textPayload, jsonPayload, or protoPayload. This also may be passed as a raw any_pb2.Any if the protoPayload could not be deserialized.
  • logger (Logger) – the logger used to write the entry.
  • insert_id (str) – (optional) the ID used to identify an entry uniquely.
  • timestamp (datetime.datetime) – (optional) timestamp for the entry
  • labels (dict) – (optional) mapping of labels for the entry
  • severity (str) – (optional) severity of event being logged.
  • http_request (dict) – (optional) info about HTTP request associated with the entry
  • resource (Resource) – (Optional) Monitored resource of the entry
parse_message(message)[source]#

Parse payload into a protobuf message.

Mutates the passed-in message in place.

Parameters:message (Protobuf message) – the message to be logged
class google.cloud.logging.entries.StructEntry(payload, logger, insert_id=None, timestamp=None, labels=None, severity=None, http_request=None, resource=None)[source]#

Bases: google.cloud.logging.entries._BaseEntry

Entry created with jsonPayload.

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

class google.cloud.logging.entries.TextEntry(payload, logger, insert_id=None, timestamp=None, labels=None, severity=None, http_request=None, resource=None)[source]#

Bases: google.cloud.logging.entries._BaseEntry

Entry created with textPayload.

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

google.cloud.logging.entries.logger_name_from_path(path)[source]#

Validate a logger URI path and get the logger name.

Parameters:path (str) – URI path for a logger API request.
Return type:str
Returns:Logger name parsed from path.
Raises:ValueError if the path is ill-formed or if the project from the path does not agree with the project passed in.