Skip to content

Commit 5f45a48

Browse files
authored
ref(remix): Use debug instead of logger (#16988)
resolves #16938
1 parent e07cdfd commit 5f45a48

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

packages/remix/src/client/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { logger } from '@sentry/core';
1+
import { debug } from '@sentry/core';
22
import { DEBUG_BUILD } from '../utils/debug-build';
33

44
export * from '@sentry/react';
@@ -17,7 +17,7 @@ export { browserTracingIntegration } from './browserTracingIntegration';
1717
*/
1818
export async function captureRemixServerException(err: unknown, name: string, request: Request): Promise<void> {
1919
DEBUG_BUILD &&
20-
logger.warn(
20+
debug.warn(
2121
'`captureRemixServerException` is a server-only function and should not be called in the browser. ' +
2222
'This function is a no-op in the browser environment.',
2323
);

packages/remix/src/client/performance.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Client, StartSpanOptions } from '@sentry/core';
22
import {
3+
debug,
34
getActiveSpan,
45
getCurrentScope,
56
getRootSpan,
67
isNodeEnv,
7-
logger,
88
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
99
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
1010
} from '@sentry/core';
@@ -119,7 +119,7 @@ export function withSentry<P extends Record<string, unknown>, R extends React.Co
119119
if (!_useEffect || !_useLocation || !_useMatches) {
120120
DEBUG_BUILD &&
121121
!isNodeEnv() &&
122-
logger.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
122+
debug.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
123123

124124
// @ts-expect-error Setting more specific React Component typing for `R` generic above
125125
// will break advanced type inference done by react router params

packages/remix/src/server/errors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import type { RequestEventData, Span } from '@sentry/core';
1111
import {
1212
addExceptionMechanism,
1313
captureException,
14+
debug,
1415
getClient,
1516
handleCallbackErrors,
16-
logger,
1717
objectify,
1818
winterCGRequestToRequestData,
1919
} from '@sentry/core';
@@ -46,7 +46,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
4646
// Skip capturing if the request is aborted as Remix docs suggest
4747
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
4848
if (request.signal.aborted) {
49-
DEBUG_BUILD && logger.warn('Skipping capture of aborted request');
49+
DEBUG_BUILD && debug.warn('Skipping capture of aborted request');
5050
return;
5151
}
5252

@@ -55,7 +55,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
5555
try {
5656
normalizedRequest = winterCGRequestToRequestData(request);
5757
} catch (e) {
58-
DEBUG_BUILD && logger.warn('Failed to normalize Remix request');
58+
DEBUG_BUILD && debug.warn('Failed to normalize Remix request');
5959
}
6060

6161
const objectifiedErr = objectify(err);

packages/remix/src/server/instrumentServer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
import type { RequestEventData, Span, TransactionSource, WrappedFunction } from '@sentry/core';
1717
import {
1818
continueTrace,
19+
debug,
1920
fill,
2021
getActiveSpan,
2122
getClient,
@@ -24,7 +25,6 @@ import {
2425
hasSpansEnabled,
2526
isNodeEnv,
2627
loadModule,
27-
logger,
2828
SEMANTIC_ATTRIBUTE_SENTRY_OP,
2929
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3030
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
@@ -73,7 +73,7 @@ export function sentryHandleError(err: unknown, { request }: DataFunctionArgs):
7373
}
7474

7575
captureRemixServerException(err, 'remix.server.handleError', request).then(null, e => {
76-
DEBUG_BUILD && logger.warn('Failed to capture Remix Server exception.', e);
76+
DEBUG_BUILD && debug.warn('Failed to capture Remix Server exception.', e);
7777
});
7878
}
7979

@@ -220,7 +220,7 @@ function makeWrappedRootLoader() {
220220
// We skip injection of trace and baggage in those cases.
221221
// For `redirect`, a valid internal redirection target will have the trace and baggage injected.
222222
if (isRedirectResponse(res) || isCatchResponse(res)) {
223-
DEBUG_BUILD && logger.warn('Skipping injection of trace and baggage as the response does not have a body');
223+
DEBUG_BUILD && debug.warn('Skipping injection of trace and baggage as the response does not have a body');
224224
return res;
225225
} else {
226226
const data = await extractData(res);
@@ -235,7 +235,7 @@ function makeWrappedRootLoader() {
235235
},
236236
);
237237
} else {
238-
DEBUG_BUILD && logger.warn('Skipping injection of trace and baggage as the response body is not an object');
238+
DEBUG_BUILD && debug.warn('Skipping injection of trace and baggage as the response body is not an object');
239239
return res;
240240
}
241241
}
@@ -289,7 +289,7 @@ function wrapRequestHandler<T extends ServerBuild | (() => ServerBuild | Promise
289289
try {
290290
normalizedRequest = winterCGRequestToRequestData(request);
291291
} catch (e) {
292-
DEBUG_BUILD && logger.warn('Failed to normalize Remix request');
292+
DEBUG_BUILD && debug.warn('Failed to normalize Remix request');
293293
}
294294

295295
if (options?.instrumentTracing && resolvedRoutes) {
@@ -447,7 +447,7 @@ export function instrumentServer(options?: { instrumentTracing?: boolean }): voi
447447
}>('@remix-run/server-runtime', module);
448448

449449
if (!pkg) {
450-
DEBUG_BUILD && logger.warn('Remix SDK was unable to require `@remix-run/server-runtime` package.');
450+
DEBUG_BUILD && debug.warn('Remix SDK was unable to require `@remix-run/server-runtime` package.');
451451

452452
return;
453453
}

packages/remix/src/server/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Integration } from '@sentry/core';
2-
import { applySdkMetadata, logger } from '@sentry/core';
2+
import { applySdkMetadata, debug } from '@sentry/core';
33
import type { NodeClient, NodeOptions } from '@sentry/node';
44
import { getDefaultIntegrations as getDefaultNodeIntegrations, init as nodeInit, isInitialized } from '@sentry/node';
55
import { DEBUG_BUILD } from '../utils/debug-build';
@@ -26,7 +26,7 @@ export function init(options: RemixOptions): NodeClient | undefined {
2626
applySdkMetadata(options, 'remix', ['remix', 'node']);
2727

2828
if (isInitialized()) {
29-
DEBUG_BUILD && logger.log('SDK already initialized');
29+
DEBUG_BUILD && debug.log('SDK already initialized');
3030

3131
return;
3232
}

packages/remix/src/utils/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ActionFunctionArgs, LoaderFunctionArgs, ServerBuild } from '@remix-run/node';
22
import type { AgnosticRouteObject } from '@remix-run/router';
33
import type { Span, TransactionSource } from '@sentry/core';
4-
import { logger } from '@sentry/core';
4+
import { debug } from '@sentry/core';
55
import { DEBUG_BUILD } from './debug-build';
66
import { getRequestMatch, matchServerRoutes } from './vendor/response';
77

@@ -39,7 +39,7 @@ export async function storeFormDataKeys(
3939
}
4040
});
4141
} catch (e) {
42-
DEBUG_BUILD && logger.warn('Failed to read FormData from request', e);
42+
DEBUG_BUILD && debug.warn('Failed to read FormData from request', e);
4343
}
4444
}
4545

packages/remix/test/integration/test/server/utils/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as http from 'http';
22
import { AddressInfo } from 'net';
33
import * as path from 'path';
44
import { createRequestHandler } from '@remix-run/express';
5-
import { logger } from '@sentry/core';
5+
import { debug } from '@sentry/core';
66
import type { EnvelopeItemType, Event, TransactionEvent } from '@sentry/core';
77
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
88
import * as Sentry from '@sentry/node';
@@ -46,7 +46,7 @@ async function makeRequest(
4646
} catch (e) {
4747
// We sometimes expect the request to fail, but not the test.
4848
// So, we do nothing.
49-
logger.warn(e);
49+
debug.warn(e);
5050
}
5151
}
5252

@@ -195,7 +195,7 @@ class TestEnv {
195195

196196
this._closeServer()
197197
.catch(e => {
198-
logger.warn(e);
198+
debug.warn(e);
199199
})
200200
.finally(() => {
201201
resolve(envelopes);

0 commit comments

Comments
 (0)