Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yblok13
Copy link

@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
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.

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.

None yet

3 participants