mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 05:07:35 +00:00
add console log service to cli
This commit is contained in:
@@ -31,7 +31,7 @@ import { mkdirp, writeFile } from 'vs/base/node/pfs';
|
||||
import { getBaseLabel } from 'vs/base/common/labels';
|
||||
import { IStateService } from 'vs/platform/state/node/state';
|
||||
import { StateService } from 'vs/platform/state/node/stateService';
|
||||
import { ILogService, getLogLevel } from 'vs/platform/log/common/log';
|
||||
import { ILogService, getLogLevel, LogLevel, ConsoleLogService, MultiplexLogService } from 'vs/platform/log/common/log';
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { areSameExtensions, adoptToGalleryExtensionId, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -78,7 +78,8 @@ export class Main {
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@INativeEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
|
||||
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService
|
||||
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
) { }
|
||||
|
||||
async run(argv: NativeParsedArgs): Promise<void> {
|
||||
@@ -127,6 +128,10 @@ export class Main {
|
||||
}
|
||||
|
||||
private async installExtensions(extensions: string[], builtinExtensionIds: string[], isMachineScoped: boolean, force: boolean): Promise<void> {
|
||||
if (this.logService.getLevel() === LogLevel.Trace || this.logService.getLevel() === LogLevel.Debug) {
|
||||
console.time('Installing Extensions');
|
||||
}
|
||||
|
||||
const failed: string[] = [];
|
||||
const installedExtensionsManifests: IExtensionManifest[] = [];
|
||||
if (extensions.length) {
|
||||
@@ -193,6 +198,10 @@ export class Main {
|
||||
await this.updateLocalizationsCache();
|
||||
}
|
||||
|
||||
if (this.logService.getLevel() === LogLevel.Trace || this.logService.getLevel() === LogLevel.Debug) {
|
||||
console.timeEnd('Installing Extensions');
|
||||
}
|
||||
|
||||
if (failed.length) {
|
||||
throw new Error(localize('installation failed', "Failed Installing Extensions: {0}", failed.join(', ')));
|
||||
}
|
||||
@@ -357,7 +366,13 @@ export async function main(argv: NativeParsedArgs): Promise<void> {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
const environmentService = new NativeEnvironmentService(argv);
|
||||
const logService: ILogService = new SpdLogService('cli', environmentService.logsPath, getLogLevel(environmentService));
|
||||
const logLevel = getLogLevel(environmentService);
|
||||
const loggers: ILogService[] = [];
|
||||
loggers.push(new SpdLogService('cli', environmentService.logsPath, logLevel));
|
||||
if (logLevel === LogLevel.Trace) {
|
||||
loggers.push(new ConsoleLogService(logLevel));
|
||||
}
|
||||
const logService = new MultiplexLogService(loggers);
|
||||
process.once('exit', () => logService.dispose());
|
||||
logService.info('main', argv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user