如何开启Firebase Javascript客户端中的日志记录? [英] How do I turn on logging in the Firebase Javascript client?

查看:110
本文介绍了如何开启Firebase Javascript客户端中的日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个Node.js模块连接到firebase。我的Javascript代码应该是写数据到我的firebase,但事实并非如此。我也没有看到任何错误,警告等登录到控制台。那么,如何为firebase JS客户端启动日志记录来查看实际发生的事情?这样的事情是否存在?我试图搜索firebase API文档,但找不到任何东西。

我正在运行我的节点模块 node myModule.js

code> Mac OS X 10.9中的终端,以防万一。\\ b $ b

解决方案

打开日志记录功能可以调用:

  Firebase.enableLogging(true); 

它会登录到控制台。这个日志记录主要是为了内部调试的目的,它不是超级用户友好的。如果你想以编程方式捕获消息,而不是直接发送到控制台,你可以选择传递一个函数enableLogging:

Firebase.enableLogging(函数(logMessage)){
//给消息添加一个时间戳
console。 log(new Date()。toISOString()+':'+ logMessage);
});


I'm connecting to firebase from a Node.js module. My Javascript code is supposed to be writing data to my firebase, but it isn't. I'm also not seeing any errors, warnins, etc. logged to the console. So how do I crank up logging for the firebase JS client to see what's actually going on? Does such a thing exist? I tried searching the firebase API docs, but couldn't find anything.

I'm running my Node module with node myModule.js from the terminal in Mac OS X 10.9, in case it matters.

解决方案

To turn on logging, you can call:

Firebase.enableLogging(true);

And it'll log to the console. This logging is mostly meant for internal debugging purposes though; it's not super user-friendly. But hopefully it'll help.

If you want to capture the messages programmatically instead of send them directly to the console, you can alternatively pass a function to enableLogging:

Firebase.enableLogging(function(logMessage) {
  // Add a timestamp to the messages.
  console.log(new Date().toISOString() + ': ' + logMessage);
});

这篇关于如何开启Firebase Javascript客户端中的日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆