@@ -5,6 +5,7 @@ import remoteBindingsWorkerPath from "worker:remoteBindings/ProxyServerWorker";
55import { logger } from "../../logger" ;
66import { getBasePath } from "../../paths" ;
77import { startWorker } from "../startDevWorker" ;
8+ import type { LoggerLevel } from "../../logger" ;
89import type { StartDevWorkerInput , Worker } from "../startDevWorker" ;
910import type { Config } from "@cloudflare/workers-utils" ;
1011import type { RemoteProxyConnectionString } from "miniflare" ;
@@ -45,11 +46,7 @@ export async function startRemoteProxySession(
4546 port : await getPort ( ) ,
4647 } ,
4748 inspector : false ,
48- logLevel :
49- // If the logger has a logLevel of "debug" it means that the user is likely trying to debug some issue,
50- // so we should respect that here as well for the remote proxy session. In any other case, to avoid noisy
51- // logs, we just simply fall back to "error"
52- logger . loggerLevel === "debug" ? "debug" : "error" ,
49+ logLevel : getStartWorkerLogLevel ( logger . loggerLevel ) ,
5350 } ,
5451 bindings : rawBindings ,
5552 } ) . catch ( ( startWorkerError ) => {
@@ -114,3 +111,27 @@ export type RemoteProxySession = Pick<Worker, "ready" | "dispose"> & {
114111 updateBindings : ( bindings : StartDevWorkerInput [ "bindings" ] ) => Promise < void > ;
115112 remoteProxyConnectionString : RemoteProxyConnectionString ;
116113} ;
114+
115+ /**
116+ * Gets the log level to use for the remote worker.
117+ *
118+ * @param wranglerLogLevel The log level set for the Wrangler process.
119+ * @returns The log level to use for the remove worker.
120+ */
121+ function getStartWorkerLogLevel ( wranglerLogLevel : LoggerLevel ) : LoggerLevel {
122+ switch ( wranglerLogLevel ) {
123+ case "debug" :
124+ // If the `logLevel` is "debug" it means that the user is likely trying to debug some issue,
125+ // so we should respect that here as well for the remote proxy session.
126+ return "debug" ;
127+
128+ case "none" :
129+ // If the `logLevel` is "none" it means that the user is trying to silence all output,
130+ // so we should respect that here as well for the remote proxy session.
131+ return "none" ;
132+
133+ default :
134+ // In any other case we want to default to "error" to avoid noisy logs
135+ return "error" ;
136+ }
137+ }
0 commit comments