diff --git a/packages/react-native/src/integrations/console.ts b/packages/react-native/src/integrations/console.ts index 56d70897..f7495303 100644 --- a/packages/react-native/src/integrations/console.ts +++ b/packages/react-native/src/integrations/console.ts @@ -33,18 +33,24 @@ export const INJECT_DEBUG = ` export type LogType = "log" | "error" | "warn"; export const handleLog = (type: LogType, message: string) => { - const parsedMessage = JSON.parse(message); + const [formatMessage, ...parsedMessage] = JSON.parse(message); + const webviewMark = "(WebView) "; + + const webviewMarkedMessage = + typeof formatMessage === "string" + ? [webviewMark + formatMessage, ...parsedMessage] + : [webviewMark, formatMessage, ...parsedMessage]; switch (type) { case "log": { - console.log("(WebView)", parsedMessage); + console.log(...webviewMarkedMessage); break; } case "error": { - console.error("(WebView)", parsedMessage); + console.error(...webviewMarkedMessage); break; } case "warn": { - console.warn("(WebView)", parsedMessage); + console.warn(...webviewMarkedMessage); break; } } diff --git a/packages/web/package.json b/packages/web/package.json index 1871e7c7..9aa7643c 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -38,4 +38,4 @@ "devDependencies": { "esbuild": "^0.19.4" } -} +} \ No newline at end of file