【问题标题】:How to get structured logs in Firebase CLI?如何在 Firebase CLI 中获取结构化日志?
【发布时间】:2021-01-07 10:00:40
【问题描述】:

我有一个节点脚本,可以打印我所有的 firebase 云函数生成的日志。

const { execSync } = require("child_process");
const cmd = "firebase functions:log";
let options = {
    encoding: 'utf8'
}
let output = execSync(cmd, options)

console.log(output)

输出如下所示:

2021-01-06T09:06:05.541212726Z D saveGarment: Function execution took 736 ms, finished with status code: 204
2021-01-06T09:06:10.844901031Z D saveGarment: Function execution started
2021-01-06T09:06:16.153Z ? saveGarment: CORE
2021-01-06T09:06:18.134508823Z D saveGarment: Function execution took 7470 ms, finished with status code: 200
2021-01-06T09:06:19.546Z ? saveGarment: { message: 'fail' }

脚本的输出是字符串的形式。有没有办法以 JSON / 任何其他结构化格式接收所有日志,还是我们需要使用字符串解析?

【问题讨论】:

    标签: javascript firebase console google-cloud-functions command-line-interface


    【解决方案1】:

    here 所述,您可以通过多种方式将数据发送到日志。

    根据您的 cmets 判断,我建议您检查示例 here,因为它包含您似乎试图发送到日志的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2011-02-07
      相关资源
      最近更新 更多