社区连接器 Logger.log 不解析 jsonPayload 中提供的严重性字段

问题描述 投票:0回答:1

我正在尝试从我的 Google Apps 脚本 - Data Studio 社区连接器代码记录 JSON 对象到 Stackdriver Logging,如官方文档中所述

使用

console.log(jsonObject)
将jsonObject转换为字符串。没用。

使用

Logger.log(jsonObject)
代替,在日志条目的 jsonPayload 属性内解析 jsonObject 。好。

但是 所有日志条目都以 INFO 严重级别插入

如果我在 jsonObject 中包含严重性属性,严重性不会按预期进行解析

我尝试了一些选项,包括将严重性设置为字符串“ERROR”或数字 500,但它不起作用。

我从社区连接器代码中尝试过的一些示例:

Logger.log({
  message: 'This is the message / title for the log entry. Works fine',
  severity: 'ERROR',
  otherData: {
    userId: '459',
    connectorType: 'blahblah',
    includeFilters: true
  }
});

Logger.log({
  message: 'This is the message / title for the log entry. Works fine',
  severity: 500,
  otherData: {
    userId: '459',
    connectorType: 'blahblah',
    includeFilters: true
  }
});

如您所见,严重性属性永远不会被解析为严重性级别。

google-apps-script logging google-cloud-functions looker-studio google-cloud-stackdriver
1个回答
0
投票

Logger
其实还有更多可用的方法:
'warning', 'config', 'severe', 'info', 'fine', 'finer', 'finest'

它们仍然没有证件,但工作得很好。

© www.soinside.com 2019 - 2024. All rights reserved.