Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/browser/mainThreadConsole.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
7
import { MainContext, MainThreadConsoleShape } from '../common/extHost.protocol.js';
8
import { IEnvironmentService } from '../../../platform/environment/common/environment.js';
9
import { IRemoteConsoleLog, log } from '../../../base/common/console.js';
10
import { logRemoteEntry, logRemoteEntryIfError } from '../../services/extensions/common/remoteConsoleUtil.js';
11
import { parseExtensionDevOptions } from '../../services/extensions/common/extensionDevOptions.js';
12
import { ILogService } from '../../../platform/log/common/log.js';
13
14
@extHostNamedCustomer(MainContext.MainThreadConsole)
15
export class MainThreadConsole implements MainThreadConsoleShape {
16
17
private readonly _isExtensionDevTestFromCli: boolean;
18
19
constructor(
20
_extHostContext: IExtHostContext,
21
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
22
@ILogService private readonly _logService: ILogService,
23
) {
24
const devOpts = parseExtensionDevOptions(this._environmentService);
25
this._isExtensionDevTestFromCli = devOpts.isExtensionDevTestFromCli;
26
}
27
28
dispose(): void {
29
//
30
}
31
32
$logExtensionHostMessage(entry: IRemoteConsoleLog): void {
33
if (this._isExtensionDevTestFromCli) {
34
// If running tests from cli, log to the log service everything
35
logRemoteEntry(this._logService, entry);
36
} else {
37
// Log to the log service only errors and log everything to local console
38
logRemoteEntryIfError(this._logService, entry, 'Extension Host');
39
log(entry, 'Extension Host');
40
}
41
}
42
}
43
44