Skip to content

chore: add trace to CONSOLE_LEVELS #5249

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

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/integrations/test/captureconsole.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ describe('CaptureConsole setup', () => {
expect(global.console.error).not.toBe(originalConsole.error);
expect(global.console.log).not.toBe(originalConsole.log);
expect(global.console.assert).not.toBe(originalConsole.assert);
expect(global.console.trace).not.toBe(originalConsole.trace);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a result of adding trace to CONSOLE_LEVELS, we are now monkeypatching everything but console.table.

I am not sure whether we want this or not. I would appreciate someone double-checking this.

Also, why are we not monkeypathcing console.table as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we want this. Don't know why we're not using table, but there are a few things to consider: 1. it has sort of a different API than the other methods 2. No IE11 support


// any other fields should not have been patched
expect(global.console.trace).toBe(originalConsole.trace);
expect(global.console.table).toBe(originalConsole.table);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const global = getGlobalObject<Window | NodeJS.Global>();
/** Prefix for logging strings */
const PREFIX = 'Sentry Logger ';

export const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert'] as const;
export const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] as const;

type LoggerMethod = (...args: unknown[]) => void;
type LoggerConsoleMethods = Record<typeof CONSOLE_LEVELS[number], LoggerMethod>;
Expand Down