我尝试在Python中使用Stackdriver Logging Client Libraries检索BigQuery审计日志。在
根据the tutorial,以下代码应该能够获取日志条目:
for entry in client.list_entries():
do_something_with(entry)
但是,这个迭代器只返回ProtobufEntry
,我无法找到如何从这个对象获取实际的日志消息。在
上述代码生成以下输出:
$ python log_test.py
<class 'google.cloud.logging.entries.ProtobufEntry'>
<class 'google.cloud.logging.entries.ProtobufEntry'>
<class 'google.cloud.logging.entries.ProtobufEntry'>
....
但是,我找不到任何解析这些对象的方法。在
如何解析实际的日志消息?在
ProtobufEntry
的字段列在here中。如果有效负载是None
,请使用payload_pb
,就像我在code中发现的那样。在以下片段对我有用:
相关问题 更多 >
编程相关推荐