Path: blob/main/src/vs/workbench/api/browser/mainThreadConsole.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';6import { MainContext, MainThreadConsoleShape } from '../common/extHost.protocol.js';7import { IEnvironmentService } from '../../../platform/environment/common/environment.js';8import { IRemoteConsoleLog, log } from '../../../base/common/console.js';9import { logRemoteEntry, logRemoteEntryIfError } from '../../services/extensions/common/remoteConsoleUtil.js';10import { parseExtensionDevOptions } from '../../services/extensions/common/extensionDevOptions.js';11import { ILogService } from '../../../platform/log/common/log.js';1213@extHostNamedCustomer(MainContext.MainThreadConsole)14export class MainThreadConsole implements MainThreadConsoleShape {1516private readonly _isExtensionDevTestFromCli: boolean;1718constructor(19_extHostContext: IExtHostContext,20@IEnvironmentService private readonly _environmentService: IEnvironmentService,21@ILogService private readonly _logService: ILogService,22) {23const devOpts = parseExtensionDevOptions(this._environmentService);24this._isExtensionDevTestFromCli = devOpts.isExtensionDevTestFromCli;25}2627dispose(): void {28//29}3031$logExtensionHostMessage(entry: IRemoteConsoleLog): void {32if (this._isExtensionDevTestFromCli) {33// If running tests from cli, log to the log service everything34logRemoteEntry(this._logService, entry);35} else {36// Log to the log service only errors and log everything to local console37logRemoteEntryIfError(this._logService, entry, 'Extension Host');38log(entry, 'Extension Host');39}40}41}424344