E53E Error logs always show up in Cloud Error Reporting by inlined · Pull Request #1141 · firebase/firebase-functions · GitHub
[go: up one dir, main page]

Skip to content

Conversation

inlined
Copy link
Member
@inlined inlined commented Jun 15, 2022

Fixes #954.

  1. Removed support for Node 8 and 10 unstructured logging since we no longer support those versions of Node.
  2. Wrap all logging.error messages in an Error if none of the args are an error.

(2) makes sure that we get a stack trace in the log message, which is required for the Cloud Run data plane to send the log line to Cloud Error Reporting, where it shows up in the Firebase "Health" tab.

Tested with the following sample:

import { onRequest } from 'firebase-functions/v2/https';
import * as logger from 'firebase-functions/logger';

export const func = onRequest((req, res) => {
    logger.info("This is an info log");
    logger.error("This is an error log");
    logger.info("This is an info log with an error suffix", new Error("suffix"));
    logger.error("This is an error log with an error suffix", new Error("suffix"));
    res.send("OK");
    throw new Error("This is an unhandled error");
});

Cloud error reporting recorded all logger.error lines and the unhandled exception. The case with an Error suffix did not nest errors, which would cause the stack trace to be repeated.

@inlined inlined requested review from colerogers and taeold June 15, 2022 21:48
@inlined inlined merged commit ea5edf9 into launch.next Jun 17, 2022
@inlined inlined deleted the inlined.error-logging branch June 17, 2022 20:52
@taeold taeold added this to the v4 milestone Jun 24, 2022
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.

3 participants

0