Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Update logging mechanism to not log sources (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
digeff authored and roblourens committed Sep 19, 2018
1 parent 31d032a commit 8f8724f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/chrome/chromeConnection.ts
Expand Up @@ -62,7 +62,13 @@ class LoggingSocket extends WebSocket {

if (msgObj && !(msgObj.method && msgObj.method.startsWith('Network.'))) {
// Not really the right place to examine the content of the message, but don't log annoying Network activity notifications.
logger.verbose('← From target: ' + msgStr);
if ((msgObj.result && msgObj.result.scriptSource)) {
// If this message contains the source of a script, we log everything but the source
msgObj.result.scriptSource = '<removed script source for logs>';
logger.verbose('← From target: ' + JSON.stringify(msgObj));
} else {
logger.verbose('← From target: ' + msgStr);
}
}
});
}
Expand Down
20 changes: 20 additions & 0 deletions src/chrome/chromeDebugSession.ts
Expand Up @@ -284,6 +284,26 @@ export class ChromeDebugSession extends LoggingDebugSession implements IObservab
this.reportTimingsWhileStartingUpIfNeeded(/*requestedContentWasDetected*/false, /*reasonForNotDetected*/'shutdown');
super.shutdown();
}

public sendResponse(response: DebugProtocol.Response): void {
const originalLogVerbose = logger.verbose;
try {
logger.verbose = textToLog => {
if (response && response.command === 'source' && response.body && response.body.content) {
const clonedResponse = Object.assign({}, response);
clonedResponse.body = Object.assign({}, response.body);
clonedResponse.body.content = '<removed script source for logs>';
return originalLogVerbose.call(logger, `To client: ${JSON.stringify(clonedResponse)}`);
} else {
return originalLogVerbose.call(logger, textToLog);
}
};
super.sendResponse(response);
} finally {
logger.verbose = originalLogVerbose;
}
}

}

function logVersionInfo(): void {
Expand Down

0 comments on commit 8f8724f

Please sign in to comment.