Skip to content

Conversation

@yblok13
Copy link
Contributor

@yblok13 yblok13 commented Jul 18, 2023

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 yblok13 changed the title Update index.ts Add trace property to logs created via logger.write() Jul 18, 2023
@jiangbo0216
Copy link

What is the reason behind this modification?

@yblok13
Copy link
Contributor Author

yblok13 commented Sep 13, 2023

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.

@lox
Copy link

lox commented Oct 13, 2023

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

@taeold
Copy link
Contributor

taeold commented Aug 26, 2024

Very reasonable change. thanks for the contribution

@taeold taeold added this pull request to the merge queue Aug 26, 2024
@taeold taeold removed this pull request from the merge queue due to the queue being cleared Aug 26, 2024
@taeold taeold added this pull request to the merge queue Aug 26, 2024
Merged via the queue into firebase:master with commit 0878a8a Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants