Skip to content

Commit cb88e70

Browse files
feat(core)!: Remove deprecated logger (#17061)
BREAKING CHANGE In #16901 we deprecated the `logger` export from `@sentry/core`. This PR removes it for the v10 release. --------- Co-authored-by: Andrei Borza <[email protected]>
1 parent 74b680d commit cb88e70

File tree

5 files changed

+7
-72
lines changed

5 files changed

+7
-72
lines changed

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Updates and fixes for version 9 will be published as `SentryNodeServerlessSDKv9`
4141

4242
- `BaseClient` was removed, use `Client` as a direct replacement.
4343
- `hasTracingEnabled` was removed, use `hasSpansEnabled` as a direct replacement.
44+
- `logger` and type `Logger` were removed, use `debug` and type `SentryDebugLogger` instead.
4445

4546
## No Version Support Timeline
4647

dev-packages/e2e-tests/test-applications/nuxt-3/server/plugins/customNitroErrorHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Context, GLOBAL_OBJ, flush, logger, vercelWaitUntil } from '@sentry/core';
1+
import { Context, GLOBAL_OBJ, flush, debug, vercelWaitUntil } from '@sentry/core';
22
import * as SentryNode from '@sentry/node';
33
import { H3Error } from 'h3';
44
import type { CapturedErrorContext } from 'nitropack';
@@ -74,10 +74,10 @@ async function flushWithTimeout(): Promise<void> {
7474
const isDebug = sentryClient ? sentryClient.getOptions().debug : false;
7575

7676
try {
77-
isDebug && logger.log('Flushing events...');
77+
isDebug && debug.log('Flushing events...');
7878
await flush(2000);
79-
isDebug && logger.log('Done flushing events');
79+
isDebug && debug.log('Done flushing events');
8080
} catch (e) {
81-
isDebug && logger.log('Error while flushing events:\n', e);
81+
isDebug && debug.log('Error while flushing events:\n', e);
8282
}
8383
}

packages/core/src/carrier.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { AsyncContextStrategy } from './asyncContext/types';
33
import type { Client } from './client';
44
import type { Scope } from './scope';
55
import type { SerializedLog } from './types-hoist/log';
6-
import type { Logger } from './utils/debug-logger';
76
import { SDK_VERSION } from './utils/version';
87
import { GLOBAL_OBJ } from './utils/worldwide';
98

@@ -26,9 +25,6 @@ export interface SentryCarrier {
2625
globalScope?: Scope;
2726
defaultIsolationScope?: Scope;
2827
defaultCurrentScope?: Scope;
29-
/** @deprecated Logger is no longer set. Instead, we keep enabled state in loggerSettings. */
30-
// eslint-disable-next-line deprecation/deprecation
31-
logger?: Logger;
3228
loggerSettings?: { enabled: boolean };
3329
/**
3430
* A map of Sentry clients to their log buffers.

packages/core/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ export {
161161
isVueViewModel,
162162
} from './utils/is';
163163
export { isBrowser } from './utils/isBrowser';
164-
// eslint-disable-next-line deprecation/deprecation
165-
export { CONSOLE_LEVELS, consoleSandbox, debug, logger, originalConsoleMethods } from './utils/debug-logger';
166-
// eslint-disable-next-line deprecation/deprecation
167-
export type { Logger, SentryDebugLogger } from './utils/debug-logger';
164+
export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger';
165+
export type { SentryDebugLogger } from './utils/debug-logger';
168166
export {
169167
addContextToFrame,
170168
addExceptionMechanism,

packages/core/src/utils/debug-logger.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@ import { DEBUG_BUILD } from '../debug-build';
33
import type { ConsoleLevel } from '../types-hoist/instrument';
44
import { GLOBAL_OBJ } from './worldwide';
55

6-
/**
7-
* A Sentry Logger instance.
8-
*
9-
* @deprecated Use {@link debug} instead with the {@link SentryDebugLogger} type.
10-
*/
11-
export interface Logger {
12-
disable(): void;
13-
enable(): void;
14-
isEnabled(): boolean;
15-
log(...args: Parameters<typeof console.log>): void;
16-
info(...args: Parameters<typeof console.info>): void;
17-
warn(...args: Parameters<typeof console.warn>): void;
18-
error(...args: Parameters<typeof console.error>): void;
19-
debug(...args: Parameters<typeof console.debug>): void;
20-
assert(...args: Parameters<typeof console.assert>): void;
21-
trace(...args: Parameters<typeof console.trace>): void;
22-
}
23-
246
export interface SentryDebugLogger {
257
disable(): void;
268
enable(): void;
@@ -115,18 +97,6 @@ function error(...args: Parameters<typeof console.error>): void {
11597
_maybeLog('error', ...args);
11698
}
11799

118-
function _debug(...args: Parameters<typeof console.debug>): void {
119-
_maybeLog('debug', ...args);
120-
}
121-
122-
function assert(...args: Parameters<typeof console.assert>): void {
123-
_maybeLog('assert', ...args);
124-
}
125-
126-
function trace(...args: Parameters<typeof console.trace>): void {
127-
_maybeLog('trace', ...args);
128-
}
129-
130100
function _maybeLog(level: ConsoleLevel, ...args: Parameters<(typeof console)[typeof level]>): void {
131101
if (!DEBUG_BUILD) {
132102
return;
@@ -147,36 +117,6 @@ function _getLoggerSettings(): { enabled: boolean } {
147117
return getGlobalSingleton('loggerSettings', () => ({ enabled: false }));
148118
}
149119

150-
/**
151-
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
152-
* The logger is a singleton on the carrier, to ensure that a consistent logger is used throughout the SDK.
153-
*
154-
* @deprecated Use {@link debug} instead.
155-
*/
156-
export const logger = {
157-
/** Enable logging. */
158-
enable,
159-
/** Disable logging. */
160-
disable,
161-
/** Check if logging is enabled. */
162-
isEnabled,
163-
/** Log a message. */
164-
log,
165-
/** Log level info */
166-
info,
167-
/** Log a warning. */
168-
warn,
169-
/** Log an error. */
170-
error,
171-
/** Log a debug message. */
172-
debug: _debug,
173-
/** Log an assertion. */
174-
assert,
175-
/** Log a trace. */
176-
trace,
177-
// eslint-disable-next-line deprecation/deprecation
178-
} satisfies Logger;
179-
180120
/**
181121
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
182122
*/

0 commit comments

Comments
 (0)