Steve K Steve K - 6 months ago 80
Node.js Question

How do I turn on logging in the Firebase Javascript client?

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.

Answer

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);
});