debug: call to native console methods in web worker ext host development
Fixes #119417
This commit is contained in:
parent
5fa18996fc
commit
7b11e6519e
1 changed files with 6 additions and 2 deletions
|
@ -70,7 +70,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||||
|
|
||||||
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
|
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
|
||||||
const mainThreadConsole = this._extHostContext.getProxy(MainContext.MainThreadConsole);
|
const mainThreadConsole = this._extHostContext.getProxy(MainContext.MainThreadConsole);
|
||||||
wrapConsoleMethods(mainThreadConsole);
|
wrapConsoleMethods(mainThreadConsole, this._initData.environment.isExtensionDevelopmentDebug);
|
||||||
|
|
||||||
// initialize API and register actors
|
// initialize API and register actors
|
||||||
const apiFactory = this._instaService.invokeFunction(createApiFactoryAndRegisterActors);
|
const apiFactory = this._instaService.invokeFunction(createApiFactoryAndRegisterActors);
|
||||||
|
@ -173,15 +173,19 @@ function ensureSuffix(path: string, suffix: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copied from bootstrap-fork.js
|
// copied from bootstrap-fork.js
|
||||||
function wrapConsoleMethods(service: MainThreadConsoleShape) {
|
function wrapConsoleMethods(service: MainThreadConsoleShape, callToNative: boolean) {
|
||||||
wrap('info', 'log');
|
wrap('info', 'log');
|
||||||
wrap('log', 'log');
|
wrap('log', 'log');
|
||||||
wrap('warn', 'warn');
|
wrap('warn', 'warn');
|
||||||
wrap('error', 'error');
|
wrap('error', 'error');
|
||||||
|
|
||||||
function wrap(method: 'error' | 'warn' | 'info' | 'log', severity: 'error' | 'warn' | 'log') {
|
function wrap(method: 'error' | 'warn' | 'info' | 'log', severity: 'error' | 'warn' | 'log') {
|
||||||
|
const original = console[method];
|
||||||
console[method] = function () {
|
console[method] = function () {
|
||||||
service.$logExtensionHostMessage({ type: '__$console', severity, arguments: safeToArray(arguments) });
|
service.$logExtensionHostMessage({ type: '__$console', severity, arguments: safeToArray(arguments) });
|
||||||
|
if (callToNative) {
|
||||||
|
original.apply(console, arguments as any);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue