Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
Custom logger in Firestore to create statistics on operations?

How can I sniff all traffic in Firestore JS SDK?

To explain in more detail, the following code enables verbose logging into console.

import { setLogLevel } from 'firebase/firestore'
setLogLevel('debug')

Now, everytime a network communication happens, in the console there are outputs like:

[2022-09-28T12:00:21.878Z] @firebase/firestore: Firestore (9.6.10): Connection WebChannel received: {"documentChange":{"document":{"name":"projects/mu-project/databases/(default)/documents/my_collection/sHM7OvtpEygAKQBawxha","fields":{ ...

Is it possible to subscribe to such logs with a custom callback, instead of printing it in console, so I can analyze the communication?

Something like:

import { setLogLevel, setLogger } from 'firebase/firestore'
setLogLevel('debug')
setLogger((message, payload) => {
 // custom stuff
})

It is intended to create statistics on writes and reads, that are intended to be used on FE in realtime.

almost 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

It's possible in that you can build your own version of the SDK and make it do whatever you want. It's open source.

Otherwise, no, it's not possible.

You're probably better off instrumenting your own application code to make it capture the things it's doing with Firestore.

almost 4 years ago · Santiago Trujillo Relatório

0

I have found onLog function which can be used to register a callback on every produced log message. However, it does not solve the question precisely, because the function does not intercept the logging, and therefore, cannot mute the output to the console. It will produce a lot of debug messages which is not desired in the production deployment.

import { onLog, setLogLevel } from 'firebase/app'

setLogLevel('debug') // must be used to track the traffic
onLog((args) => {
  console.log('Custom log callback: ', args)
}, {level: 'debug'})

Also note that onLog must be called after the Firestore component is initialized.

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda