如何从Firebase模拟器中查看可读的控制台日志?

huangapple go评论89阅读模式
英文:

how to view readable console logs from firebase simulator?

问题

我正在构建一些 Node.js 云函数,并在本地使用 Firebase 模拟器运行。日志以庞大且难看的块状形式输出。双重转义,术语颜色以 Unicode 形式,换行破损,非常糟糕...

是否有办法使这些输出更可读?

当我将相同的代码作为单元测试运行而不使用 Google Stack 时,输出很干净,所以肯定与 Firebase 模拟器管道处理一切有关。

我有一些使用 functions.logger 的日志,我想这是无法挽救的,因为它是为 cloudlogger 设计的。安息吧。

但我还使用了一些简单的 debug('...'),我希望能够从中获取人类可读的输出,甚至是漂亮格式化和带颜色的输出!

在 Firebase 工具的 Web 浏览器中看起来好一些,但我更喜欢只使用控制台日志。

我用于运行 Firebase 应用程序的命令不会将输出通过任何东西进行处理:

firebase emulators:start --only functions

如何从Firebase模拟器中查看可读的控制台日志?

英文:

I'm building some nodeJS cloud functions and running locally with the firebase simulator. The logs come out as huge ugly blobs. double escaped, term colors as unicode, line wrapping broken, just horrible...

Is there a way to make this output more readable?

When I run same code as unit tests without the google stack, it's clean, so it's def something to do with the firebase simulator pipeline crunching everything down.

I have some logs that use the functions.logger, and I guess thats beyond salvation as it's designed for cloudlogger. RIP.

But I'm also using some simple debug('...') which I was hoping to get human readable - even nicely formatted and colorized! - output from.

It looks a bit better in the firebase tools web browser but i'd prefer to just have console logs.

My cmd to run the FB app doesn't pipe the output through anything:

firebase emulators:start --only functions

如何从Firebase模拟器中查看可读的控制台日志?

答案1

得分: 1

看起来这个功能仍然处于Alpha状态。在GitHub上提出了一个关于在函数模拟器和Shell中记录级别格式的功能请求1。您也可以在那里提出您的关切。

目前,您可以使用firebase emulators:start --inspect-functions命令在浏览器开发工具中查看Firebase模拟器日志,如此处所讨论的那样。

英文:

Seems like this feature is still in Alpha state. There is a feature request raised for log level formatting in functions emulator and shell in github. You can also add your concern over there.

Currently, You can use firebase emulators:start --inspect-functions to view Firebase emulator logs in browser devtools, as discussed here

huangapple
  • 本文由 发表于 2023年1月4日 15:55:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75002413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定