Python 如何解析GCP上Stackdriver的审核日志项

Python 如何解析GCP上Stackdriver的审核日志项,python,google-bigquery,google-cloud-python,google-cloud-stackdriver,google-cloud-logging,Python,Google Bigquery,Google Cloud Python,Google Cloud Stackdriver,Google Cloud Logging,我正在尝试使用Python检索BigQuery审核日志 根据,以下代码应该能够获取日志条目: for entry in client.list_entries(): do_something_with(entry) 但是,这个迭代器只返回ProtobufEntry,我找不到如何从这个对象获取实际的日志消息 for entry in client.list_entries(): print type(entry) 上述代码生成以下输出: $ python log_test.py

我正在尝试使用Python检索BigQuery审核日志

根据,以下代码应该能够获取日志条目:

for entry in client.list_entries():
    do_something_with(entry)
但是,这个迭代器只返回
ProtobufEntry
,我找不到如何从这个对象获取实际的日志消息

for entry in client.list_entries():
    print type(entry)
上述代码生成以下输出:

$ python log_test.py
<class 'google.cloud.logging.entries.ProtobufEntry'>
<class 'google.cloud.logging.entries.ProtobufEntry'>
<class 'google.cloud.logging.entries.ProtobufEntry'>
....
$python log\u test.py
....
但是,我找不到任何方法来解析这些对象


如何解析实际日志消息?

列出了
协议的字段。如果有效负载为
None
请使用
payload\u pb
而不是我在中找到的

以下代码片段对我很有用:

from google.cloud import logging

client = logging.Client()
for entry in client.list_entries():
        timestamp = entry.timestamp.isoformat()
        print('* {}: {}'.format
              (timestamp, entry.payload_pb))

payload\u pb
是Protobuf格式的二进制blob。知道如何解析它吗?