Skip to content

fix: Remove critical log severity level #15824

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
Mar 25, 2025
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
32 changes: 0 additions & 32 deletions packages/browser/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,36 +257,4 @@ export function fatal(message: ParameterizedString, attributes?: Log['attributes
captureLog('fatal', message, attributes);
}

/**
* @summary Capture a log with the `critical` level. Requires `_experiments.enableLogs` to be enabled.
*
* @param message - The message to log.
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { security: 'breach', severity: 'high' }.
*
* @example
*
* ```
* Sentry.logger.critical('Security breach detected', {
* type: 'unauthorized_access',
* user: '132123',
* endpoint: '/api/admin',
* timestamp: Date.now()
* });
* ```
*
* @example With template strings
*
* ```
* Sentry.logger.critical(Sentry.logger.fmt`Multiple failed login attempts from user ${user}`, {
* attempts: 10,
* timeWindow: '5m',
* blocked: true,
* timestamp: Date.now()
* });
* ```
*/
export function critical(message: ParameterizedString, attributes?: Log['attributes']): void {
captureLog('critical', message, attributes);
}

export { fmt } from '@sentry/core';
1 change: 0 additions & 1 deletion packages/browser/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ describe('SentryBrowser', () => {
expect(logger.warn).toBeDefined();
expect(logger.error).toBeDefined();
expect(logger.fatal).toBeDefined();
expect(logger.critical).toBeDefined();
});
});
});
Expand Down
15 changes: 0 additions & 15 deletions packages/browser/test/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('Logger', () => {
expect(logger.warn).toBeTypeOf('function');
expect(logger.error).toBeTypeOf('function');
expect(logger.fatal).toBeTypeOf('function');
expect(logger.critical).toBeTypeOf('function');
});

it('should call _INTERNAL_captureLog with trace level', () => {
Expand Down Expand Up @@ -150,20 +149,6 @@ describe('Logger', () => {
undefined,
);
});

it('should call _INTERNAL_captureLog with critical level', () => {
logger.critical('Test critical message', { key: 'value' });
expect(mockCaptureLog).toHaveBeenCalledWith(
{
level: 'critical',
message: 'Test critical message',
attributes: { key: 'value' },
severityNumber: undefined,
},
expect.any(Object),
undefined,
);
});
});

describe('Automatic flushing', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/log.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ParameterizedString } from './parameterize';

export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'critical';
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
Copy link
Member

Choose a reason for hiding this comment

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

this is technically breaking 🤔 but if it breaks, I guess it is necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing should be using this yet, and yup we need to change it.


export type SerializedLogAttributeValueType =
| {
Expand Down
28 changes: 0 additions & 28 deletions packages/node/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,32 +194,4 @@ export function fatal(...args: CaptureLogArgs): void {
captureLog('fatal', ...args);
}

/**
* @summary Capture a log with the `critical` level. Requires `_experiments.enableLogs` to be enabled.
*
* You can either pass a message and attributes or a message template, params and attributes.
*
* @example
*
* ```
* Sentry.logger.critical('Service health check failed', {
* service: 'payment-gateway',
* status: 'DOWN',
* lastHealthy: '2024-03-20T09:55:00Z'
* });
* ```
*
* @example With template strings
*
* ```
* Sentry.logger.critical('Service %s is %s',
* ['payment-gateway', 'DOWN'],
* { lastHealthy: '2024-03-20T09:55:00Z' }
* );
* ```
*/
export function critical(...args: CaptureLogArgs): void {
captureLog('critical', ...args);
}

export { fmt } from '@sentry/core';
10 changes: 0 additions & 10 deletions packages/node/test/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('Node Logger', () => {
expect(nodeLogger.warn).toBeTypeOf('function');
expect(nodeLogger.error).toBeTypeOf('function');
expect(nodeLogger.fatal).toBeTypeOf('function');
expect(nodeLogger.critical).toBeTypeOf('function');
});

it('should call _INTERNAL_captureLog with trace level', () => {
Expand Down Expand Up @@ -88,15 +87,6 @@ describe('Node Logger', () => {
attributes: { key: 'value' },
});
});

it('should call _INTERNAL_captureLog with critical level', () => {
nodeLogger.critical('Test critical message', { key: 'value' });
expect(mockCaptureLog).toHaveBeenCalledWith({
level: 'critical',
message: 'Test critical message',
attributes: { key: 'value' },
});
});
});

describe('Template string logging', () => {
Expand Down
Loading