Skip to content

feat(core)!: Remove deprecated logger #17061

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 3 commits into from
Jul 18, 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
1 change: 1 addition & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Updates and fixes for version 9 will be published as `SentryNodeServerlessSDKv9`

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

## No Version Support Timeline

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, GLOBAL_OBJ, flush, logger, vercelWaitUntil } from '@sentry/core';
import { Context, GLOBAL_OBJ, flush, debug, vercelWaitUntil } from '@sentry/core';
import * as SentryNode from '@sentry/node';
import { H3Error } from 'h3';
import type { CapturedErrorContext } from 'nitropack';
Expand Down Expand Up @@ -74,10 +74,10 @@ async function flushWithTimeout(): Promise<void> {
const isDebug = sentryClient ? sentryClient.getOptions().debug : false;

try {
isDebug && logger.log('Flushing events...');
isDebug && debug.log('Flushing events...');
await flush(2000);
isDebug && logger.log('Done flushing events');
isDebug && debug.log('Done flushing events');
} catch (e) {
isDebug && logger.log('Error while flushing events:\n', e);
isDebug && debug.log('Error while flushing events:\n', e);
}
}
4 changes: 0 additions & 4 deletions packages/core/src/carrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { AsyncContextStrategy } from './asyncContext/types';
import type { Client } from './client';
import type { Scope } from './scope';
import type { SerializedLog } from './types-hoist/log';
import type { Logger } from './utils/debug-logger';
import { SDK_VERSION } from './utils/version';
import { GLOBAL_OBJ } from './utils/worldwide';

Expand All @@ -26,9 +25,6 @@ export interface SentryCarrier {
globalScope?: Scope;
defaultIsolationScope?: Scope;
defaultCurrentScope?: Scope;
/** @deprecated Logger is no longer set. Instead, we keep enabled state in loggerSettings. */
// eslint-disable-next-line deprecation/deprecation
logger?: Logger;
loggerSettings?: { enabled: boolean };
/**
* A map of Sentry clients to their log buffers.
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ export {
isVueViewModel,
} from './utils/is';
export { isBrowser } from './utils/isBrowser';
// eslint-disable-next-line deprecation/deprecation
export { CONSOLE_LEVELS, consoleSandbox, debug, logger, originalConsoleMethods } from './utils/debug-logger';
// eslint-disable-next-line deprecation/deprecation
export type { Logger, SentryDebugLogger } from './utils/debug-logger';
export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger';
export type { SentryDebugLogger } from './utils/debug-logger';
export {
addContextToFrame,
addExceptionMechanism,
Expand Down
60 changes: 0 additions & 60 deletions packages/core/src/utils/debug-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ import { DEBUG_BUILD } from '../debug-build';
import type { ConsoleLevel } from '../types-hoist/instrument';
import { GLOBAL_OBJ } from './worldwide';

/**
* A Sentry Logger instance.
*
* @deprecated Use {@link debug} instead with the {@link SentryDebugLogger} type.
*/
export interface Logger {
disable(): void;
enable(): void;
isEnabled(): boolean;
log(...args: Parameters<typeof console.log>): void;
info(...args: Parameters<typeof console.info>): void;
warn(...args: Parameters<typeof console.warn>): void;
error(...args: Parameters<typeof console.error>): void;
debug(...args: Parameters<typeof console.debug>): void;
assert(...args: Parameters<typeof console.assert>): void;
trace(...args: Parameters<typeof console.trace>): void;
}

export interface SentryDebugLogger {
disable(): void;
enable(): void;
Expand Down Expand Up @@ -115,18 +97,6 @@ function error(...args: Parameters<typeof console.error>): void {
_maybeLog('error', ...args);
}

function _debug(...args: Parameters<typeof console.debug>): void {
_maybeLog('debug', ...args);
}

function assert(...args: Parameters<typeof console.assert>): void {
_maybeLog('assert', ...args);
}

function trace(...args: Parameters<typeof console.trace>): void {
_maybeLog('trace', ...args);
}

function _maybeLog(level: ConsoleLevel, ...args: Parameters<(typeof console)[typeof level]>): void {
if (!DEBUG_BUILD) {
return;
Expand All @@ -147,36 +117,6 @@ function _getLoggerSettings(): { enabled: boolean } {
return getGlobalSingleton('loggerSettings', () => ({ enabled: false }));
}

/**
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
* The logger is a singleton on the carrier, to ensure that a consistent logger is used throughout the SDK.
*
* @deprecated Use {@link debug} instead.
*/
export const logger = {
/** Enable logging. */
enable,
/** Disable logging. */
disable,
/** Check if logging is enabled. */
isEnabled,
/** Log a message. */
log,
/** Log level info */
info,
/** Log a warning. */
warn,
/** Log an error. */
error,
/** Log a debug message. */
debug: _debug,
/** Log an assertion. */
assert,
/** Log a trace. */
trace,
// eslint-disable-next-line deprecation/deprecation
} satisfies Logger;

/**
* This is a logger singleton which either logs things or no-ops if logging is not enabled.
*/
Expand Down
Loading