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

189
Visualizações
How to get logs to show up as errors in Cloud Functions for Firebase

When an error occurs in my cloud function it is not showing up in the firebase console or logs as an error.

I would like the error to show up on the health tab of functions page in the Firebase console so I am aware of the error. Currently it only shows up in the function logs as a normal log entry (see image). enter image description here

How can I adjust my code so that an error occurs in the cloud function so I can see it. Note that this function is called by a webhook from Stripe.

export const stripeWHEInvoiceCreated = functions
  .region('us-east1')
  .https.onRequest(async (req, res) => {
  try {
    const sig = req.headers['stripe-signature'];
    const event = stripe.webhooks.constructEvent(
      (req as any).rawBody,
      sig,
      webhookSecretInvoiceCreated
    );
    await internalInvoiceCreated(event);

    res.sendStatus(200);
  } catch (err) {
    res.status(400).send(err);
  }
});

export const internalInvoiceCreated = async(event: any) => {
  try {
     // Do stuff
 } catch(err) {
    console.log('An error occurred');
    console.log(err);
    throw err;
  }

  return;
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The easiest thing to do is use console.error() instead of console.log().

If you want to do logging the best possible way, you should use the logging functions of the functions SDK, as shown in the documentation.

const functions = require("firebase-functions");
functions.logger.error(...);
about 4 years ago · Juan Pablo Isaza 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