【问题标题】:See console logs in the firebase server functions查看 firebase 服务器功能中的控制台日志
【发布时间】:2020-12-29 18:23:15
【问题描述】:

我在 firebase 函数日志控制台中看到大量垃圾邮件日志消息,但我看不到我记录的那些,所以我希望看到的那些。

我的代码:

const createNotification = ((notification) => {
  return admin.firestore().collection('notifications')
    .add(notification)
    .then(doc => console.log('notification added', doc)); //THIS IS THE LOG I EXPECT TO SEE
});

exports.userJoined = functions.auth.user()
  .onCreate(user => {
    
    return admin.firestore().collection('users')
      .doc(user.uid).get().then(doc => {

        const newUser = doc.data();
        const notification = {
          content: 'Joined the party',
          user: `${newUser.firstName} ${newUser.lastName}`,
          time: admin.firestore.FieldValue.serverTimestamp()
        };

        return createNotification(notification);

      });
});

在promise中我也试过了:.then(() => console.log('notification added', notification)); 通知是在数据库中创建的,但控制台中没有日志。 这次我很幸运,代码可以正常工作,但如果代码不能正常工作,我希望能够将内容注销。

在我的 reduxfirebase 配置中,我将 enableLogging 设置为 true,以防万一。

export const reduxFirebase = {
  userProfile: 'users',
  useFirestoreForProfile: true,
  enableLogging: true
}

在 firebase 中调试服务器功能执行的任何提示也将受到赞赏。谢谢

编辑:获得的 firebase 日志的图像:

预期日志:

【问题讨论】:

  • 您可以分享您在函数控制台中所做 看到的日志吗?您的代码显然没有任何问题,因此查看您得到的输出会有所帮助。
  • 问题中的更新图像。建议下拉的箭头不显示任何内容

标签: node.js firebase google-cloud-functions


【解决方案1】:

尝试将console.log 替换为functions.logger.info -- 我认为您的日志正在以一种令人困惑的方式爆炸成多行。

【讨论】:

  • 成功了。非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-22
  • 2020-10-19
  • 1970-01-01
相关资源
最近更新 更多