【问题标题】:Do not show Firebase Cloud Functions default log lines不显示 Firebase Cloud Functions 默认日志行
【发布时间】:2019-12-11 23:25:57
【问题描述】:

我使用 express 作为 Firebase Cloud Functions 的服务器。 我的服务器中有很多端点,它们都由快速路由器管理。 然后我将 express 实例传递给 firebase,效果很好。

我的问题是每次调用端点时,控制台中都会出现以下日志行:

i  functions: Beginning execution of "app"
i  functions: Finished "app" in ~5s

虽然很高兴知道我的端点需要多长时间才能完成,但这些日志行对我来说毫无意义,因为它们总是只提到“应用程序”。没有有用的信息。

这是合法的并且符合我的配置,但我想摆脱那些日志行。我在官方文档和模块源代码中都找不到任何提及它们的内容。

您知道如何控制 Cloud Functions 默认日志记录吗?


我的index.js 文件与此类似:

const functions = require('firebase-functions');
const express = require('express');
const app = express();

app.use('/api/users', require('./routes/users'));

app.get('/', (req, res) => {
    res.send("Hello world!");
});

exports.app = functions.https.onRequest(app);

firebase.json:

{
  "functions": {
    "source": "."
  }
}

我使用firebase serve --only functions 在本地运行服务器。

【问题讨论】:

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


    【解决方案1】:

    除了您在该页面上立即看到的内容外,Firebase 控制台中的日志不可配置。如果您想要更自定义的日志记录体验,您应该查看StackdriverStackdriver Logging 以创建更复杂的日志视图。

    【讨论】:

      猜你喜欢
      • 2018-06-06
      • 2022-06-13
      • 2017-11-19
      • 2020-01-24
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 2022-07-27
      • 2019-07-26
      相关资源
      最近更新 更多