【发布时间】:2023-03-21 00:19:01
【问题描述】:
我正在使用firebase功能,这是我第一次使用节点。
我的问题很简单,至少我是这么认为的。
我创建了一个简单的函数,理论上,如果一个新字段被添加到数据库中,这个函数必须做出反应。
我的代码如下:
const functions = require('firebase-functions');
'use strict';
exports.newItem = functions.database.ref('/test')
.onCreate((snapshot, context) => {
snapshot = change.after;
const val = snapshot.val();
console.log('i´m alive');
return null;
})
;
我正在寻找在哪里查看我在“newItem”函数中的日志是否显示。
当我阅读时,我使用控制台中的“firebase 函数:日志”,但这会返回以前的日志,而不是实时的。
我还看到了使用:gcloud functions logs read,as I read here。
但这总是返回:-bash: gcloud: command not found 我已经安装了“gcloud functions”,但还是迷路了。
我觉得问题是否解释得不是很好,但总而言之,我寻找一个可以实时查看日志的控制台,就像它使用标签 logcat 的 intelij 或 android studio 一样。
我希望为初学者提供解释。
提前致谢和问候。
【问题讨论】:
标签: node.js function firebase logging google-cloud-functions