firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

Add trace property to logs created via logger.write()

Open yblok13 opened this issue 2 years ago • 3 comments

Description

Calling logger.write() does not automatically add the traceId in logs like calling logger.log(), logger.error(), etc. Since the latter functions call logger.write() anyways, I moved the snippet of code setting the traceId to the write function.

Code sample

const { logger } = require("firebase-functions/v2/logger");

logger.write("TEST LOG", { severity: "NOTICE" });
// Prior to change, traceId was not set.

yblok13 avatar Jul 18 '23 01:07 yblok13

What is the reason behind this modification?

jiangbo0216 avatar Aug 21 '23 08:08 jiangbo0216

With console, you can only use debug, log, warning, and error. Logger uses much more fine tuned verbose levels. However, using those verbose levels does not attach the stack trace in Google Cloud Logging. This pull request adds the stack trace to all verbose levels.

yblok13 avatar Sep 13 '23 08:09 yblok13

It also makes it impossible to get trace information on critical+ log levels.

lox avatar Oct 13 '23 02:10 lox