Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there someway to disable all firebase logging to console?

I have created some unit tests for my firebase security rules. Part of this testing is trying to do illegal operations and asserting that they fail.

My problem has to do with noise; when I run the tests using nodeunit, the firebase client spits out several logs similar to this:

FIREBASE WARNING: set at /user failed: permission_denied

I do not want this output when intentionally doing illegal operations as it just results in noise and confusion.

like image 323
Tore Avatar asked Jul 31 '14 14:07

Tore


People also ask

What is Google Firebase logging?

Firebase provides tools for tracking analytics, reporting and fixing app crashes, creating marketing and product experiment. Firebase offers a number of services, including: Analytics – Google Analytics for Firebase offers free, unlimited reporting on as many as 500 separate events.


1 Answers

In our testing suite, we rewrite process.stderr.write to only ignore firebase warnings like so:

Javascript

process.stderr.write = (function(write) {
  return function() {
    if (!arguments[0].includes("FIREBASE WARNING"))
      write.apply(process.stderr, arguments);
  };
}(process.stderr.write));

Typescript (including tslint fix)

process.stderr.write = (() => {
    // tslint:disable-next-line:no-unbound-method
    const write = process.stderr.write;

    return function () {
        if (!(arguments[0] as string).includes("FIREBASE WARNING")) {
            return write.apply(process.stderr, arguments);
        }
    };
})();
like image 180
BradMcDanel Avatar answered Oct 23 '22 06:10

BradMcDanel