Skip to content

feat(core): Deprecate logger in favor of debug #17040

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 8 commits into from
Jul 16, 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
16 changes: 16 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ These docs walk through how to migrate our JavaScript SDKs through different maj
- Upgrading from [SDK 7.x to 8.x](./docs/migration/v7-to-v8.md)
- Upgrading from [SDK 8.x to 9.x](#upgrading-from-8x-to-9x)

# Deprecations in 9.x

## Deprecated `@sentry/core` SDK internal `logger` export

The internal SDK `logger` export from `@sentry/core` has been deprecated in favor of the `debug` export. `debug` only exposes `log`, `warn`, and `error` methods but is otherwise identical to `logger`. Note that this deprecation does not affect the `logger` export from other packages (like `@sentry/browser` or `@sentry/node`) which is used for Sentry Logging.

```js
import { logger, debug } from '@sentry/core';

// before
logger.info('This is an info message');

// after
debug.log('This is an info message');
```

# Upgrading from 8.x to 9.x

Version 9 of the Sentry JavaScript SDK primarily introduces API cleanup and version support changes.
Expand Down
20 changes: 11 additions & 9 deletions dev-packages/opentelemetry-v2-tests/test/helpers/initOtel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ATTR_SERVICE_VERSION,
SEMRESATTRS_SERVICE_NAMESPACE,
} from '@opentelemetry/semantic-conventions';
import { getClient, logger, SDK_VERSION } from '@sentry/core';
import { debug as debugLogger, getClient, SDK_VERSION } from '@sentry/core';
import { wrapContextManagerClass } from '../../../../packages/opentelemetry/src/contextManager';
import { DEBUG_BUILD } from '../../../../packages/opentelemetry/src/debug-build';
import { SentryPropagator } from '../../../../packages/opentelemetry/src/propagator';
Expand All @@ -25,21 +25,23 @@ export function initOtel(): void {

if (!client) {
DEBUG_BUILD &&
logger.warn(
debugLogger.warn(
'No client available, skipping OpenTelemetry setup. This probably means that `Sentry.init()` was not called before `initOtel()`.',
);
return;
}

if (client.getOptions().debug) {
const otelLogger = new Proxy(logger as typeof logger & { verbose: (typeof logger)['debug'] }, {
get(target, prop, receiver) {
const actualProp = prop === 'verbose' ? 'debug' : prop;
return Reflect.get(target, actualProp, receiver);
diag.setLogger(
{
error: debugLogger.error,
warn: debugLogger.warn,
info: debugLogger.log,
debug: debugLogger.log,
verbose: debugLogger.log,
},
});

diag.setLogger(otelLogger, DiagLogLevel.DEBUG);
DiagLogLevel.DEBUG,
);
}

setupEventContextTrace(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
addBreadcrumb,
debug,
getClient,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
setTag,
Expand Down Expand Up @@ -503,7 +502,7 @@ describe('Integration | Transactions', () => {
vi.setSystemTime(now);

const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
vi.spyOn(debug, 'log').mockImplementation(msg => logs.push(msg));

const transactions: Event[] = [];

Expand Down Expand Up @@ -555,7 +554,7 @@ describe('Integration | Transactions', () => {
vi.setSystemTime(now);

const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
vi.spyOn(debug, 'log').mockImplementation(msg => logs.push(msg));

const transactions: Event[] = [];

Expand Down Expand Up @@ -606,7 +605,7 @@ describe('Integration | Transactions', () => {
vi.setSystemTime(now);

const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
vi.spyOn(debug, 'log').mockImplementation(msg => logs.push(msg));

const transactions: Event[] = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getClient, getIsolationScope } from './currentScopes';
import type { Breadcrumb, BreadcrumbHint } from './types-hoist/breadcrumb';
import { consoleSandbox } from './utils/logger';
import { consoleSandbox } from './utils/debug-logger';
import { dateTimestampInSeconds } from './utils/time';

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/carrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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/logger';
import type { Logger } from './utils/debug-logger';
import { SDK_VERSION } from './utils/version';
import { GLOBAL_OBJ } from './utils/worldwide';

Expand All @@ -27,6 +27,7 @@ export interface SentryCarrier {
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 };
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import type { Span, SpanAttributes, SpanContextData, SpanJSON } from './types-ho
import type { StartSpanOptions } from './types-hoist/startSpanOptions';
import type { Transport, TransportMakeRequestResponse } from './types-hoist/transport';
import { createClientReportEnvelope } from './utils/clientreport';
import { debug } from './utils/debug-logger';
import { dsnToString, makeDsn } from './utils/dsn';
import { addItemToEnvelope, createAttachmentEnvelopeItem } from './utils/envelope';
import { getPossibleEventMessages } from './utils/eventUtils';
import { isParameterizedString, isPlainObject, isPrimitive, isThenable } from './utils/is';
import { debug } from './utils/logger';
import { merge } from './utils/merge';
import { checkOrSetAlreadyCaught, uuid4 } from './utils/misc';
import { parseSampleRate } from './utils/parseSampleRate';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/eventProcessors.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DEBUG_BUILD } from './debug-build';
import type { Event, EventHint } from './types-hoist/event';
import type { EventProcessor } from './types-hoist/eventprocessor';
import { debug } from './utils/debug-logger';
import { isThenable } from './utils/is';
import { debug } from './utils/logger';
import { SyncPromise } from './utils/syncpromise';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type { Primitive } from './types-hoist/misc';
import type { Session, SessionContext } from './types-hoist/session';
import type { SeverityLevel } from './types-hoist/severity';
import type { User } from './types-hoist/user';
import { debug } from './utils/debug-logger';
import { isThenable } from './utils/is';
import { debug } from './utils/logger';
import { uuid4 } from './utils/misc';
import type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';
import { parseEventHintOrCaptureContext } from './utils/prepareEvent';
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ export {
isVueViewModel,
} from './utils/is';
export { isBrowser } from './utils/isBrowser';
export { CONSOLE_LEVELS, consoleSandbox, debug, logger, originalConsoleMethods } from './utils/logger';
export type { Logger } from './utils/logger';
// 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 } from './utils/debug-logger';
export {
addContextToFrame,
addExceptionMechanism,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/instrument/console.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';
import { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/logger';
import { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';
import { fill } from '../utils/object';
import { GLOBAL_OBJ } from '../utils/worldwide';
import { addHandler, maybeInstrument, triggerHandlers } from './handlers';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/instrument/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEBUG_BUILD } from '../debug-build';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { getFunctionName } from '../utils/stacktrace';

export type InstrumentHandlerType =
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DEBUG_BUILD } from './debug-build';
import type { Event, EventHint } from './types-hoist/event';
import type { Integration, IntegrationFn } from './types-hoist/integration';
import type { Options } from './types-hoist/options';
import { debug } from './utils/logger';
import { debug } from './utils/debug-logger';

export const installedIntegrations: string[] = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/captureconsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addConsoleInstrumentationHandler } from '../instrument/console';
import { defineIntegration } from '../integration';
import type { CaptureContext } from '../scope';
import type { IntegrationFn } from '../types-hoist/integration';
import { CONSOLE_LEVELS } from '../utils/logger';
import { CONSOLE_LEVELS } from '../utils/debug-logger';
import { addExceptionMechanism } from '../utils/misc';
import { severityLevelFromString } from '../utils/severity';
import { safeJoin } from '../utils/string';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getClient } from '../currentScopes';
import { addConsoleInstrumentationHandler } from '../instrument/console';
import { defineIntegration } from '../integration';
import type { ConsoleLevel } from '../types-hoist/instrument';
import { CONSOLE_LEVELS } from '../utils/logger';
import { CONSOLE_LEVELS } from '../utils/debug-logger';
import { severityLevelFromString } from '../utils/severity';
import { safeJoin } from '../utils/string';
import { GLOBAL_OBJ } from '../utils/worldwide';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Event } from '../types-hoist/event';
import type { Exception } from '../types-hoist/exception';
import type { IntegrationFn } from '../types-hoist/integration';
import type { StackFrame } from '../types-hoist/stackframe';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { getFramesFromEvent } from '../utils/stacktrace';

const INTEGRATION_NAME = 'Dedupe';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/eventFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { defineIntegration } from '../integration';
import type { Event } from '../types-hoist/event';
import type { IntegrationFn } from '../types-hoist/integration';
import type { StackFrame } from '../types-hoist/stackframe';
import { debug } from '../utils/debug-logger';
import { getPossibleEventMessages } from '../utils/eventUtils';
import { debug } from '../utils/logger';
import { getEventDescription } from '../utils/misc';
import { stringMatchesSomePattern } from '../utils/string';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/extraerrordata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Contexts } from '../types-hoist/context';
import type { ExtendedError } from '../types-hoist/error';
import type { Event, EventHint } from '../types-hoist/event';
import type { IntegrationFn } from '../types-hoist/integration';
import { debug } from '../utils/debug-logger';
import { isError, isPlainObject } from '../utils/is';
import { debug } from '../utils/logger';
import { normalize } from '../utils/normalize';
import { addNonEnumerableProperty } from '../utils/object';
import { truncate } from '../utils/string';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { defineIntegration } from '../integration';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
import { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';
import type { IntegrationFn } from '../types-hoist/integration';
import { debug } from '../utils/debug-logger';
import { isPlainObject } from '../utils/is';
import { debug } from '../utils/logger';

const AUTH_OPERATIONS_TO_INSTRUMENT = [
'reauthenticate',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/logs/console-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { defineIntegration } from '../integration';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
import type { ConsoleLevel } from '../types-hoist/instrument';
import type { IntegrationFn } from '../types-hoist/integration';
import { CONSOLE_LEVELS, debug } from '../utils/debug-logger';
import { isPrimitive } from '../utils/is';
import { CONSOLE_LEVELS, debug } from '../utils/logger';
import { normalize } from '../utils/normalize';
import { GLOBAL_OBJ } from '../utils/worldwide';
import { _INTERNAL_captureLog } from './exports';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/logs/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { DEBUG_BUILD } from '../debug-build';
import type { Scope, ScopeData } from '../scope';
import type { Log, SerializedLog, SerializedLogAttributeValue } from '../types-hoist/log';
import { mergeScopeData } from '../utils/applyScopeDataToEvent';
import { consoleSandbox, debug } from '../utils/debug-logger';
import { isParameterizedString } from '../utils/is';
import { consoleSandbox, debug } from '../utils/logger';
import { _getSpanForScope } from '../utils/spanOnScope';
import { timestampInSeconds } from '../utils/time';
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './semanticAttributes';
import { startSpan, withActiveSpan } from './tracing';
import type { Span } from './types-hoist/span';
import { debug } from './utils/logger';
import { debug } from './utils/debug-logger';
import { getActiveSpan } from './utils/spanUtils';

interface MCPTransport {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/profiling.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getClient } from './currentScopes';
import { DEBUG_BUILD } from './debug-build';
import type { Profiler, ProfilingIntegration } from './types-hoist/profiling';
import { debug } from './utils/logger';
import { debug } from './utils/debug-logger';

function isProfilingIntegrationWithProfiler(
integration: ProfilingIntegration<any> | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import type { SeverityLevel } from './types-hoist/severity';
import type { Span } from './types-hoist/span';
import type { PropagationContext } from './types-hoist/tracing';
import type { User } from './types-hoist/user';
import { debug } from './utils/debug-logger';
import { isPlainObject } from './utils/is';
import { debug } from './utils/logger';
import { merge } from './utils/merge';
import { uuid4 } from './utils/misc';
import { generateTraceId } from './utils/propagationContext';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Client } from './client';
import { getCurrentScope } from './currentScopes';
import { DEBUG_BUILD } from './debug-build';
import type { ClientOptions } from './types-hoist/options';
import { consoleSandbox, debug } from './utils/logger';
import { consoleSandbox, debug } from './utils/debug-logger';

/** A class object that can instantiate Client objects. */
export type ClientClass<F extends Client, O extends ClientOptions> = new (options: O) => F;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server-runtime-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import type { ClientOptions } from './types-hoist/options';
import type { ParameterizedString } from './types-hoist/parameterize';
import type { SeverityLevel } from './types-hoist/severity';
import type { BaseTransportOptions } from './types-hoist/transport';
import { debug } from './utils/debug-logger';
import { eventFromMessage, eventFromUnknownInput } from './utils/eventbuilder';
import { isPrimitive } from './utils/is';
import { debug } from './utils/logger';
import { uuid4 } from './utils/misc';
import { resolvedSyncPromise } from './utils/syncpromise';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DEBUG_BUILD } from '../debug-build';
import { addGlobalErrorInstrumentationHandler } from '../instrument/globalError';
import { addGlobalUnhandledRejectionInstrumentationHandler } from '../instrument/globalUnhandledRejection';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { getActiveSpan, getRootSpan } from '../utils/spanUtils';
import { SPAN_STATUS_ERROR } from './spanstatus';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/idleSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON } from '../semanticAt
import type { DynamicSamplingContext } from '../types-hoist/envelope';
import type { Span } from '../types-hoist/span';
import type { StartSpanOptions } from '../types-hoist/startSpanOptions';
import { debug } from '../utils/debug-logger';
import { hasSpansEnabled } from '../utils/hasSpansEnabled';
import { debug } from '../utils/logger';
import { _setSpanForScope } from '../utils/spanOnScope';
import {
getActiveSpan,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/logSpans.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DEBUG_BUILD } from '../debug-build';
import type { Span } from '../types-hoist/span';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../semanticAttributes';
import type { Measurements, MeasurementUnit } from '../types-hoist/measurement';
import type { TimedEvent } from '../types-hoist/timedEvent';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { getActiveSpan, getRootSpan } from '../utils/spanUtils';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/sampling.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DEBUG_BUILD } from '../debug-build';
import type { Options } from '../types-hoist/options';
import type { SamplingContext } from '../types-hoist/samplingcontext';
import { debug } from '../utils/debug-logger';
import { hasSpansEnabled } from '../utils/hasSpansEnabled';
import { debug } from '../utils/logger';
import { parseSampleRate } from '../utils/parseSampleRate';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/sentrySpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
import type { SpanStatus } from '../types-hoist/spanStatus';
import type { TimedEvent } from '../types-hoist/timedEvent';
import type { TransactionSource } from '../types-hoist/transaction';
import { debug } from '../utils/logger';
import { debug } from '../utils/debug-logger';
import { generateSpanId, generateTraceId } from '../utils/propagationContext';
import {
convertSpanLinksForEnvelope,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import type { DynamicSamplingContext } from '../types-hoist/envelope';
import type { ClientOptions } from '../types-hoist/options';
import type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';
import type { StartSpanOptions } from '../types-hoist/startSpanOptions';
import { debug } from '../utils/debug-logger';
import { handleCallbackErrors } from '../utils/handleCallbackErrors';
import { hasSpansEnabled } from '../utils/hasSpansEnabled';
import { debug } from '../utils/logger';
import { parseSampleRate } from '../utils/parseSampleRate';
import { generateTraceId } from '../utils/propagationContext';
import { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';
Expand Down
Loading
Loading