Skip to content

Commit c2d0b2c

Browse files
authored
fix: Remove critical log severity level (#15824)
This isn't part of the spec, and will break ingestion if we allow things to be sent.
1 parent c14ab92 commit c2d0b2c

File tree

6 files changed

+1
-87
lines changed

6 files changed

+1
-87
lines changed

Diff for: packages/browser/src/log.ts

-32
Original file line numberDiff line numberDiff line change
@@ -257,36 +257,4 @@ export function fatal(message: ParameterizedString, attributes?: Log['attributes
257257
captureLog('fatal', message, attributes);
258258
}
259259

260-
/**
261-
* @summary Capture a log with the `critical` level. Requires `_experiments.enableLogs` to be enabled.
262-
*
263-
* @param message - The message to log.
264-
* @param attributes - Arbitrary structured data that stores information about the log - e.g., { security: 'breach', severity: 'high' }.
265-
*
266-
* @example
267-
*
268-
* ```
269-
* Sentry.logger.critical('Security breach detected', {
270-
* type: 'unauthorized_access',
271-
* user: '132123',
272-
* endpoint: '/api/admin',
273-
* timestamp: Date.now()
274-
* });
275-
* ```
276-
*
277-
* @example With template strings
278-
*
279-
* ```
280-
* Sentry.logger.critical(Sentry.logger.fmt`Multiple failed login attempts from user ${user}`, {
281-
* attempts: 10,
282-
* timeWindow: '5m',
283-
* blocked: true,
284-
* timestamp: Date.now()
285-
* });
286-
* ```
287-
*/
288-
export function critical(message: ParameterizedString, attributes?: Log['attributes']): void {
289-
captureLog('critical', message, attributes);
290-
}
291-
292260
export { fmt } from '@sentry/core';

Diff for: packages/browser/test/index.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ describe('SentryBrowser', () => {
334334
expect(logger.warn).toBeDefined();
335335
expect(logger.error).toBeDefined();
336336
expect(logger.fatal).toBeDefined();
337-
expect(logger.critical).toBeDefined();
338337
});
339338
});
340339
});

Diff for: packages/browser/test/log.test.ts

-15
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ describe('Logger', () => {
6464
expect(logger.warn).toBeTypeOf('function');
6565
expect(logger.error).toBeTypeOf('function');
6666
expect(logger.fatal).toBeTypeOf('function');
67-
expect(logger.critical).toBeTypeOf('function');
6867
});
6968

7069
it('should call _INTERNAL_captureLog with trace level', () => {
@@ -150,20 +149,6 @@ describe('Logger', () => {
150149
undefined,
151150
);
152151
});
153-
154-
it('should call _INTERNAL_captureLog with critical level', () => {
155-
logger.critical('Test critical message', { key: 'value' });
156-
expect(mockCaptureLog).toHaveBeenCalledWith(
157-
{
158-
level: 'critical',
159-
message: 'Test critical message',
160-
attributes: { key: 'value' },
161-
severityNumber: undefined,
162-
},
163-
expect.any(Object),
164-
undefined,
165-
);
166-
});
167152
});
168153

169154
describe('Automatic flushing', () => {

Diff for: packages/core/src/types-hoist/log.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ParameterizedString } from './parameterize';
22

3-
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'critical';
3+
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
44

55
export type SerializedLogAttributeValueType =
66
| {

Diff for: packages/node/src/log.ts

-28
Original file line numberDiff line numberDiff line change
@@ -194,32 +194,4 @@ export function fatal(...args: CaptureLogArgs): void {
194194
captureLog('fatal', ...args);
195195
}
196196

197-
/**
198-
* @summary Capture a log with the `critical` level. Requires `_experiments.enableLogs` to be enabled.
199-
*
200-
* You can either pass a message and attributes or a message template, params and attributes.
201-
*
202-
* @example
203-
*
204-
* ```
205-
* Sentry.logger.critical('Service health check failed', {
206-
* service: 'payment-gateway',
207-
* status: 'DOWN',
208-
* lastHealthy: '2024-03-20T09:55:00Z'
209-
* });
210-
* ```
211-
*
212-
* @example With template strings
213-
*
214-
* ```
215-
* Sentry.logger.critical('Service %s is %s',
216-
* ['payment-gateway', 'DOWN'],
217-
* { lastHealthy: '2024-03-20T09:55:00Z' }
218-
* );
219-
* ```
220-
*/
221-
export function critical(...args: CaptureLogArgs): void {
222-
captureLog('critical', ...args);
223-
}
224-
225197
export { fmt } from '@sentry/core';

Diff for: packages/node/test/log.test.ts

-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describe('Node Logger', () => {
3232
expect(nodeLogger.warn).toBeTypeOf('function');
3333
expect(nodeLogger.error).toBeTypeOf('function');
3434
expect(nodeLogger.fatal).toBeTypeOf('function');
35-
expect(nodeLogger.critical).toBeTypeOf('function');
3635
});
3736

3837
it('should call _INTERNAL_captureLog with trace level', () => {
@@ -88,15 +87,6 @@ describe('Node Logger', () => {
8887
attributes: { key: 'value' },
8988
});
9089
});
91-
92-
it('should call _INTERNAL_captureLog with critical level', () => {
93-
nodeLogger.critical('Test critical message', { key: 'value' });
94-
expect(mockCaptureLog).toHaveBeenCalledWith({
95-
level: 'critical',
96-
message: 'Test critical message',
97-
attributes: { key: 'value' },
98-
});
99-
});
10090
});
10191

10292
describe('Template string logging', () => {

0 commit comments

Comments
 (0)