Skip to content

feat: disable error logging stacktrace in message #1705

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

CorieW
Copy link
Member

@CorieW CorieW commented Jun 9, 2025

Resolves #1681

@CorieW CorieW force-pushed the @invertase/add-disable-error-traceback branch 5 times, most recently from d554ba6 to d805557 Compare June 9, 2025 16:11
@CorieW CorieW force-pushed the @invertase/add-disable-error-traceback branch from d805557 to 243c6b1 Compare June 9, 2025 16:16
@cabljac cabljac requested review from Copilot and cabljac June 16, 2025 08:34
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new global option to disable automatic inclusion of error stacktraces in logs and updates the logger and tests to respect this setting.

  • Introduce disableErrorLoggingTraceback in GlobalOptions
  • Modify entryFromArgs to skip stacktrace when the option is enabled
  • Add tests for default stacktrace inclusion and disabling behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/v2/options.ts Add disableErrorLoggingTraceback to GlobalOptions with accompanying JSDoc
src/logger/index.ts Check getGlobalOptions().disableErrorLoggingTraceback before injecting stacktrace
spec/logger.spec.ts Tests for error logging behavior with and without the new option
Comments suppressed due to low confidence (2)

src/v2/options.ts:241

  • Fix the JSDoc wording to remove the double negative, e.g. When true, the error message will not include the traceback of the error.
* When true, the error message will include not include the traceback of the error.

spec/logger.spec.ts:223

  • Consider adding a test case where logger.error is called with an actual Error object to ensure that existing Error instances aren’t wrapped with a new stacktrace.
describe("error logging stacktrace", () => {

Copy link

@cabljac cabljac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes/comments

* @remarks
* When true, the error message will include not include the traceback of the error.
*/
disableErrorLoggingTraceback?: boolean;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use "stacktrace" instead of "traceback" as afaik traceback is mostly a python term?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableErrorStackTrace or suppressErrorStack or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just went with disableErrorLoggingStacktrace, since it refers to logging. I feel like disableErrorStacktrace isn't clear enough.

disableErrorLogStacktrace could be an alternative?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya disableErrorLoggingStacktrace sounds good!

@github-project-automation github-project-automation bot moved this to Changes Requested [PR] in [Cloud] Extensions + Functions Jul 9, 2025
@cabljac cabljac force-pushed the @invertase/add-disable-error-traceback branch from 243c6b1 to 06e2743 Compare July 9, 2025 09:14
Copy link

@cabljac cabljac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-project-automation github-project-automation bot moved this from Changes Requested [PR] to Approved [PR] in [Cloud] Extensions + Functions Jul 9, 2025
@taeold
Copy link
Contributor

taeold commented Jul 11, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new global option disableErrorLoggingStacktrace to control the automatic inclusion of stack traces in error logs. The implementation logic in the logger and the option definition are generally sound, but there are opportunities to improve test quality, code readability, and the default value of the new option.

Comment on lines +227 to +233
beforeEach(() => {
setGlobalOptions(defaultOptions);
});

afterEach(() => {
setGlobalOptions(defaultOptions);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of setGlobalOptions within beforeEach and afterEach can lead to repeated calls to this function, potentially resulting in noisy test logs. Consider introducing a test-only helper function in src/v2/options.ts to reset the internal globalOptions variable to avoid this warning.

Comment on lines +238 to +239
* Defaults to false.
*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default value for disableErrorLoggingStacktrace is set to false. It would be more intuitive if the default was true, aligning with the description that states 'When true, the error message will not include the stacktrace'.

Suggested change
* Defaults to false.
*
* Defaults to true.

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.

logger.error prints the stacktrace of line where it was invoked
3 participants