【发布时间】: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