Skip to content

Commit 937a209

Browse files
committed
fix: only log when DEBUG_BUILD flag is on
1 parent abd6bb2 commit 937a209

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/nuxt/src/runtime/plugins/storage.server.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { defineNitroPlugin, useStorage } from 'nitropack/runtime';
1616
import type { Driver, Storage } from 'unstorage';
1717
// @ts-expect-error - This is a virtual module
1818
import { userStorageMounts } from '#sentry/storage-config.mjs';
19+
import { DEBUG_BUILD } from '../../common/debug-build';
1920

2021
type MaybeInstrumented<T> = T & {
2122
__sentry_instrumented__?: boolean;
@@ -53,7 +54,7 @@ export default defineNitroPlugin(async _nitroApp => {
5354
// Mounts are suffixed with a colon, so we need to add it to the set items
5455
const userMounts = new Set((userStorageMounts as string[]).map(m => `${m}:`));
5556

56-
debug.log('[storage] Starting to instrument storage drivers...');
57+
DEBUG_BUILD && debug.log('[storage] Starting to instrument storage drivers...');
5758

5859
// Get all mounted storage drivers
5960
const mounts = storage.getMounts();
@@ -76,12 +77,12 @@ export default defineNitroPlugin(async _nitroApp => {
7677
function instrumentDriver(driver: MaybeInstrumentedDriver, mountBase: string): Driver {
7778
// Already instrumented, skip...
7879
if (driver.__sentry_instrumented__) {
79-
debug.log(`[storage] Driver already instrumented: "${driver.name}". Skipping...`);
80+
DEBUG_BUILD && debug.log(`[storage] Driver already instrumented: "${driver.name}". Skipping...`);
8081

8182
return driver;
8283
}
8384

84-
debug.log(`[storage] Instrumenting driver: "${driver.name}" on mount: "${mountBase}"`);
85+
DEBUG_BUILD && debug.log(`[storage] Instrumenting driver: "${driver.name}" on mount: "${mountBase}"`);
8586

8687
// List of driver methods to instrument
8788
// get/set/remove are aliases and already use their {method}Item methods
@@ -128,7 +129,7 @@ function createMethodWrapper(
128129
async apply(target, thisArg, args) {
129130
const attributes = getSpanAttributes(methodName, driver, mountBase, args);
130131

131-
debug.log(`[storage] Running method: "${methodName}" on driver: "${driver.name ?? 'unknown'}"`);
132+
DEBUG_BUILD && debug.log(`[storage] Running method: "${methodName}" on driver: "${driver.name ?? 'unknown'}"`);
132133

133134
const spanName = KEYED_METHODS.has(methodName)
134135
? `${mountBase}${args?.[0]}`
@@ -179,7 +180,7 @@ function wrapStorageMount(storage: Storage): Storage['mount'] {
179180
}
180181

181182
function mountWithInstrumentation(base: string, driver: Driver): Storage {
182-
debug.log(`[storage] Instrumenting mount: "${base}"`);
183+
DEBUG_BUILD && debug.log(`[storage] Instrumenting mount: "${base}"`);
183184

184185
const instrumentedDriver = instrumentDriver(driver, base);
185186

0 commit comments

Comments
 (0)