diff --git a/src/chromium/crConnection.ts b/src/chromium/crConnection.ts index a3d703a054..e542ba87fd 100644 --- a/src/chromium/crConnection.ts +++ b/src/chromium/crConnection.ts @@ -60,7 +60,7 @@ export class CRConnection extends platform.EventEmitter { if (sessionId) message.sessionId = sessionId; const data = JSON.stringify(message); - this._debugProtocol('SEND ► ' + data); + this._debugProtocol('SEND ► ' + (rewriteInjectedScriptEvaluationLog(message) || data)); this._transport.send(data); return id; } @@ -192,3 +192,10 @@ function rewriteError(error: Error, message: string): Error { error.message = message; return error; } + +function rewriteInjectedScriptEvaluationLog(message: any): string | undefined { + // Injected script is very long and clutters protocol logs. + // To increase development velocity, we skip replace it with short description in the log. + if (message.method === 'Runtime.evaluate' && message.params && message.params.expression && message.params.expression.includes('src/injected/injected.ts')) + return `{"id":${message.id} [evaluate injected script]}`; +} diff --git a/src/firefox/ffConnection.ts b/src/firefox/ffConnection.ts index 09db9df2b7..1b3b83d10b 100644 --- a/src/firefox/ffConnection.ts +++ b/src/firefox/ffConnection.ts @@ -84,9 +84,9 @@ export class FFConnection extends platform.EventEmitter { } _rawSend(message: any) { - message = JSON.stringify(message); - this._debugProtocol('SEND ► ' + message); - this._transport.send(message); + const data = JSON.stringify(message); + this._debugProtocol('SEND ► ' + (rewriteInjectedScriptEvaluationLog(message) || data)); + this._transport.send(data); } async _onMessage(message: string) { @@ -226,3 +226,10 @@ function rewriteError(error: Error, message: string): Error { error.message = message; return error; } + +function rewriteInjectedScriptEvaluationLog(message: any): string | undefined { + // Injected script is very long and clutters protocol logs. + // To increase development velocity, we skip replace it with short description in the log. + if (message.method === 'Runtime.evaluate' && message.params && message.params.expression && message.params.expression.includes('src/injected/injected.ts')) + return `{"id":${message.id} [evaluate injected script]}`; +} diff --git a/src/webkit/wkConnection.ts b/src/webkit/wkConnection.ts index 2fc51a9624..7e7c5ec98b 100644 --- a/src/webkit/wkConnection.ts +++ b/src/webkit/wkConnection.ts @@ -53,9 +53,9 @@ export class WKConnection { } rawSend(message: any) { - message = JSON.stringify(message); - this._debugFunction('SEND ► ' + message); - this._transport.send(message); + const data = JSON.stringify(message); + this._debugFunction('SEND ► ' + (rewriteInjectedScriptEvaluationLog(message) || data)); + this._transport.send(data); } private _dispatchMessage(message: string) { @@ -177,3 +177,10 @@ export function rewriteError(error: Error, message: string): Error { export function isSwappedOutError(e: Error) { return e.message.includes('Target was swapped out.'); } + +function rewriteInjectedScriptEvaluationLog(message: any): string | undefined { + // Injected script is very long and clutters protocol logs. + // To increase development velocity, we skip replace it with short description in the log. + if (message.params && message.params.message && message.params.message.includes('Runtime.evaluate') && message.params.message.includes('src/injected/injected.ts')) + return `{"id":${message.id},"method":"${message.method}","params":{"message":[evaluate injected script],"targetId":"${message.params.targetId}"},"pageProxyId":${message.pageProxyId}}`; +}