我无法将有意义的错误消息记录到我的函数日志中,我想要实现的目标是让错误以“错误”日志级别出现,如下所示:实际错误日志的图像相反,我得到的是这样的:测试结果图片我正在使用以下函数来测试这一点:exports.testError = functions.https.onRequest(async (request, response) =>{ console.log('Hi'); //According to google this won't be logged as error console.error('Error'); //But these will console.error(new Error('error')); console.error('Error', new Error('error')); return response.status(500).send('Test is finished.');})第一个图像是随机错误,其目的是展示我想要实现的目标,即:将错误记录为错误。第二张图片是我的测试结果,它表明即使我遵循谷歌的指示(报告错误),它也无法按预期工作。
2 回答

侃侃无极
TA贡献2051条经验 获得超10个赞
使用 Cloud Functions 记录器 SDK,如中所述
const functions = require("firebase-functions") functions.logger.debug("debug level in web console and gcp") functions.logger.log("info level in web console and gcp") functions.logger.info("info level in web console and gcp") functions.logger.warn("info level but no icon in web console; warn icon in gcp") functions.logger.error("error level in web console and gcp")
添加回答
举报
0/150
提交
取消