大佬教程收集整理的这篇文章主要介绍了node.js – 从Google Logging API解码protoPayload,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
const Logging = require('@google-cloud/logging'); const protobuf = require('protocol-buffers'); const protoFiles = require('google-proto-files'); const protoPath = './node_modules/google-proto-files/google/cloud/audit/audit_log.proto'; const root = protoFiles.loadSync(protoPath) const AuditLog = root.lookup('google.cloud.audit.AuditLog'); const client = new Logging.v2.LoggingserviceV2Client({ projectId }); client.listLogEntriesStream({resourcenames,filter,pageSizE}) .on('data',entry => { console.log(entry); // Entry is of type AuditLog console.log(AuditLog.decode(entry.protoPayload.value.buffer)); process.exit(1) }) .on('error',e => console.error(E)) .on('end',() => console.info('END RECEIVED',arguments))
我确实收到带有protoPayloads的消息,但是在尝试解码消息时收到的错误是这样的:
Error: no such Type or Enum 'google.rpc.Status' in Type .google.cloud.audit.AuditLog
实际问题:在LogEntry中解码protoPayload字段的正确方法是什么?
谢谢!
以上是大佬教程为你收集整理的node.js – 从Google Logging API解码protoPayload全部内容,希望文章能够帮你解决node.js – 从Google Logging API解码protoPayload所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。