【问题标题】:functions.logger.warn does not display any level on the Firebase Cloud Functions logfunctions.logger.warn 不会在 Firebase Cloud Functions 日志中显示任何级别
【发布时间】:2022-06-13 21:36:24
【问题描述】:

我正在使用 functions.logger 为我的 Cloud Functions 记录事件,但我不明白为什么 Firebase 控制台(Cloud Functions 日志)没有考虑警告级别。

我对所有可用级别进行了全面测试,这是我在 Firebase 界面上的 Cloud Function 日志中的结果。警告没有显示任何级别:

在文档中,他们清楚地解释了 logger.warn 在 Cloud Functions 日志中被视为错误级别日志,但在我的测试中并非如此: https://firebase.google.com/docs/functions/writing-and-viewing-logs

logger.log() 命令具有 INFO 日志级别。

logger.info() 命令具有 INFO 日志级别。

logger.warn() 命令具有 ERROR 日志级别。

logger.error() 命令具有 ERROR 日志级别。

内部系统消息具有 DEBUG 日志级别。

考虑到我的项目确实需要警告级别,这对我来说是个大问题,警告级别可以很好地显示在 Google Cloud Platform 控制台上,但不能显示在 Firebase Cloud Functions 日志中。

【问题讨论】:

    标签: firebase google-cloud-platform google-cloud-functions


    【解决方案1】:

    documentation 声明 WARNING 消息将记录在 Firebase 控制台的函数日志中的错误级别。 但是在运行下面的代码之后

    const functions = require("firebase-functions");
    const { warn } = require("firebase-functions/lib/logger");
    // Attach structured data to the log as the last argument.
     
    // Create and Deploy Your First Cloud Functions
    //  https://firebase.google.com/docs/functions/write-firebase-functions
     
    exports.helloWorld = functions.https.onRequest((request, response) => {
     functions.logger.info("Hello logs!");
     functions.logger.warn();
     response.send("Hello from Firebase!");
    });
     
    // Attach structured data to the log as the last argument.
    warn("This is a 'WARNING' severity message with some metadata.", {
     key1: 'val1',
     key2: 'val2'
    });
     
    

    并使用 firebase deploy –only functions:helloWorld 部署它,函数的 WARNING 日志不会出现在您正确告知的任何级别。

    我希望您提出 issue in Firebase Support / issue in GitHub Firebase functions,因为问题在于 Firebase 控制台 UI/UX 日志严重性。要获得更快的解决方案,请在相应的组件中提出问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-06
      • 2019-07-06
      • 2020-06-24
      • 1970-01-01
      相关资源
      最近更新 更多