Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, warnings, 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.

like image 355
Steve K Avatar asked Mar 15 '14 03:03

Steve K


People also ask

Can you use Firebase with JavaScript?

Before you can add Firebase to your JavaScript app, you need to create a Firebase project and register your app with that project. When you register your app with Firebase, you'll get a Firebase configuration object that you'll use to connect your app with your Firebase project resources.

What is Firebase logging?

Linking your Firebase project to Cloud Logging allows you to view, search, and filter logs from your project. Firebase Hosting: After you link your project, it exports web request logs from your Firebase Hosting sites to Cloud Logging.

How do you check logs in Firebase?

You can see logs in real time using the Firebase console. Choose your project, click the Functions product on the left, then click the Logs tab.


2 Answers

In the 3.0.0 version of Firebase, this has been changed to:

firebase.database.enableLogging(true);

See enableLoggging documentation.

like image 103
mckoss Avatar answered Oct 17 '22 21:10

mckoss


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);
});
like image 20
Michael Lehenbauer Avatar answered Oct 17 '22 20:10

Michael Lehenbauer