更改 firestore-debug.log 位置

Changing firestore-debug.log location

我的 Firebase 项目中有一个观察器,它会在我更改代码时自动编译并重新启动模拟器。这很好,除了我认为由于某些竞争条件,我每次保存代码时都会得到一个新的 firestore-debug.logasidfhusudf.log 文件。我怎样才能禁用日志文件或至少更改创建日志文件的位置?

firestore-debug.log 与 firebase.json 位于同一文件夹中。您可以在 运行 命令的目录中看到它,其中包含所有请求的日志。

您正在为函数使用 typescript,因此您可以参考 documentation 函数日志如何用于 Typescript 项目:

During firebase deploy, your project's index.ts is transpiled to index.js, meaning that the Cloud Functions log will output line numbers from the index.js file and not the code you wrote. To make it easier for you to find the corresponding paths and line numbers in index.ts, firebase deploy creates functions/lib/index.js.map. You can use this source map in your preferred IDE or via a node module.

Documentation 中提到了调试输出如何存储在 firestore-debug.log 中:

A basic debug function that prints Security Rules language objects, variables and statement results as they are being evaluated by the Security Rules engine.The outputs of debug are written to firestore-debug.log. The debug function can only be called inside Rules conditions.debug function blocks are only executed by the Security Rules engine in the Firestore emulator, part of the Firebase Emulator Suite. The debug function has no effect in production.Debug logfile entries are prepended by a string identifying the Rules language data type of the log output (for example, string_value, map_value).Calls to debug can be nested.Currently, the debug feature does not support the concept of logging levels (for example, INFO, WARN, ERROR).

您还可以参考 ,其中 Kiana 和 Daniel 提供了关于如何自动禁用超过 1 个月的日志的简要说明。

You can see it directly within the Firebase console. When trying to choose the timestamp for the logs, logs older than 1 month are disabled, which means are automatically deleted.

您可以参考 documentation 以了解如何使用查询语言在 Emulator 套件中过滤日志 UI。