不显示Firebase Cloud Functions默认日志行

时间:2019-12-11 23:25:57

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

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

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

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

虽然很高兴知道我的端点完成了多少时间,但是这些日志行对我来说毫无意义,因为它们始终只提及“ app”。没有有用的信息。

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

您知道如何控制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在本地运行服务器。

1 个答案:

答案 0 :(得分:0)

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

相关问题