提交 4ecad471 编写于 作者: J Joao Moreno

fixes #39806

上级 f71f52f6
...@@ -36,7 +36,7 @@ import { ipcRenderer } from 'electron'; ...@@ -36,7 +36,7 @@ import { ipcRenderer } from 'electron';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { createSharedProcessContributions } from 'vs/code/electron-browser/contrib/contributions'; import { createSharedProcessContributions } from 'vs/code/electron-browser/contrib/contributions';
import { createLogService } from 'vs/platform/log/node/spdlogService'; import { createLogService } from 'vs/platform/log/node/spdlogService';
import { ILogService, registerGlobalLogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
export interface ISharedProcessConfiguration { export interface ISharedProcessConfiguration {
readonly machineId: string; readonly machineId: string;
...@@ -81,7 +81,6 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I ...@@ -81,7 +81,6 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
const environmentService = new EnvironmentService(initData.args, process.execPath); const environmentService = new EnvironmentService(initData.args, process.execPath);
const logService = createLogService('sharedprocess', environmentService); const logService = createLogService('sharedprocess', environmentService);
process.once('exit', () => logService.dispose()); process.once('exit', () => logService.dispose());
registerGlobalLogService(logService);
logService.info('main', JSON.stringify(configuration)); logService.info('main', JSON.stringify(configuration));
......
...@@ -21,7 +21,7 @@ import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiati ...@@ -21,7 +21,7 @@ import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiati
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ILogService, ConsoleLogMainService, MultiplexLogService, registerGlobalLogService } from 'vs/platform/log/common/log'; import { ILogService, ConsoleLogMainService, MultiplexLogService } from 'vs/platform/log/common/log';
import { StateService } from 'vs/platform/state/node/stateService'; import { StateService } from 'vs/platform/state/node/stateService';
import { IStateService } from 'vs/platform/state/common/state'; import { IStateService } from 'vs/platform/state/common/state';
import { IBackupMainService } from 'vs/platform/backup/common/backup'; import { IBackupMainService } from 'vs/platform/backup/common/backup';
...@@ -53,7 +53,6 @@ function createServices(args: ParsedArgs): IInstantiationService { ...@@ -53,7 +53,6 @@ function createServices(args: ParsedArgs): IInstantiationService {
const consoleLogService = new ConsoleLogMainService(environmentService); const consoleLogService = new ConsoleLogMainService(environmentService);
const logService = new MultiplexLogService([consoleLogService, spdlogService]); const logService = new MultiplexLogService([consoleLogService, spdlogService]);
registerGlobalLogService(logService);
process.once('exit', () => logService.dispose()); process.once('exit', () => logService.dispose());
// Eventually cleanup // Eventually cleanup
......
...@@ -36,7 +36,7 @@ import { getBaseLabel } from 'vs/base/common/labels'; ...@@ -36,7 +36,7 @@ import { getBaseLabel } from 'vs/base/common/labels';
import { IStateService } from 'vs/platform/state/common/state'; import { IStateService } from 'vs/platform/state/common/state';
import { StateService } from 'vs/platform/state/node/stateService'; import { StateService } from 'vs/platform/state/node/stateService';
import { createLogService } from 'vs/platform/log/node/spdlogService'; import { createLogService } from 'vs/platform/log/node/spdlogService';
import { registerGlobalLogService, ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { isPromiseCanceledError } from 'vs/base/common/errors'; import { isPromiseCanceledError } from 'vs/base/common/errors';
const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id); const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id);
...@@ -198,7 +198,6 @@ export function main(argv: ParsedArgs): TPromise<void> { ...@@ -198,7 +198,6 @@ export function main(argv: ParsedArgs): TPromise<void> {
const environmentService = new EnvironmentService(argv, process.execPath); const environmentService = new EnvironmentService(argv, process.execPath);
const logService = createLogService('cli', environmentService); const logService = createLogService('cli', environmentService);
process.once('exit', () => logService.dispose()); process.once('exit', () => logService.dispose());
registerGlobalLogService(logService);
logService.info('main', argv); logService.info('main', argv);
......
...@@ -11,7 +11,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions'; ...@@ -11,7 +11,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { log, LogLevel } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
export class CommandService extends Disposable implements ICommandService { export class CommandService extends Disposable implements ICommandService {
...@@ -25,14 +25,16 @@ export class CommandService extends Disposable implements ICommandService { ...@@ -25,14 +25,16 @@ export class CommandService extends Disposable implements ICommandService {
constructor( constructor(
@IInstantiationService private _instantiationService: IInstantiationService, @IInstantiationService private _instantiationService: IInstantiationService,
@IExtensionService private _extensionService: IExtensionService, @IExtensionService private _extensionService: IExtensionService,
@IContextKeyService private _contextKeyService: IContextKeyService @IContextKeyService private _contextKeyService: IContextKeyService,
@ILogService private _logService: ILogService
) { ) {
super(); super();
this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value); this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value);
} }
@log(LogLevel.Info, 'CommandService', (msg, id) => `${msg}(${id})`)
executeCommand<T>(id: string, ...args: any[]): TPromise<T> { executeCommand<T>(id: string, ...args: any[]): TPromise<T> {
this._logService.info('CommandService#executeCommand', id);
// we always send an activation event, but // we always send an activation event, but
// we don't wait for it when the extension // we don't wait for it when the extension
// host didn't yet start and the command is already registered // host didn't yet start and the command is already registered
......
...@@ -16,6 +16,7 @@ import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyServ ...@@ -16,6 +16,7 @@ import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyServ
import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices'; import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { NoopLogService } from 'vs/platform/log/common/log';
class SimpleExtensionService implements IExtensionService { class SimpleExtensionService implements IExtensionService {
_serviceBrand: any; _serviceBrand: any;
...@@ -74,7 +75,7 @@ suite('CommandService', function () { ...@@ -74,7 +75,7 @@ suite('CommandService', function () {
lastEvent = activationEvent; lastEvent = activationEvent;
return super.activateByEvent(activationEvent); return super.activateByEvent(activationEvent);
} }
}, new ContextKeyService(new SimpleConfigurationService())); }, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
return service.executeCommand('foo').then(() => { return service.executeCommand('foo').then(() => {
assert.ok(lastEvent, 'onCommand:foo'); assert.ok(lastEvent, 'onCommand:foo');
...@@ -92,7 +93,7 @@ suite('CommandService', function () { ...@@ -92,7 +93,7 @@ suite('CommandService', function () {
activateByEvent(activationEvent: string): TPromise<void> { activateByEvent(activationEvent: string): TPromise<void> {
return TPromise.wrapError<void>(new Error('bad_activate')); return TPromise.wrapError<void>(new Error('bad_activate'));
} }
}, new ContextKeyService(new SimpleConfigurationService())); }, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
return service.executeCommand('foo').then(() => assert.ok(false), err => { return service.executeCommand('foo').then(() => assert.ok(false), err => {
assert.equal(err.message, 'bad_activate'); assert.equal(err.message, 'bad_activate');
...@@ -108,7 +109,7 @@ suite('CommandService', function () { ...@@ -108,7 +109,7 @@ suite('CommandService', function () {
whenInstalledExtensionsRegistered() { whenInstalledExtensionsRegistered() {
return new TPromise<boolean>(_resolve => { /*ignore*/ }); return new TPromise<boolean>(_resolve => { /*ignore*/ });
} }
}, new ContextKeyService(new SimpleConfigurationService())); }, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
service.executeCommand('bar'); service.executeCommand('bar');
assert.equal(callCounter, 1); assert.equal(callCounter, 1);
...@@ -125,7 +126,7 @@ suite('CommandService', function () { ...@@ -125,7 +126,7 @@ suite('CommandService', function () {
whenInstalledExtensionsRegistered() { whenInstalledExtensionsRegistered() {
return new TPromise<boolean>(_resolve => { resolveFunc = _resolve; }); return new TPromise<boolean>(_resolve => { resolveFunc = _resolve; });
} }
}, new ContextKeyService(new SimpleConfigurationService())); }, new ContextKeyService(new SimpleConfigurationService()), new NoopLogService());
let r = service.executeCommand('bar'); let r = service.executeCommand('bar');
assert.equal(callCounter, 0); assert.equal(callCounter, 0);
...@@ -144,7 +145,8 @@ suite('CommandService', function () { ...@@ -144,7 +145,8 @@ suite('CommandService', function () {
let commandService = new CommandService( let commandService = new CommandService(
new InstantiationService(), new InstantiationService(),
new SimpleExtensionService(), new SimpleExtensionService(),
contextKeyService contextKeyService,
new NoopLogService()
); );
let counter = 0; let counter = 0;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { createDecorator as createServiceDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator as createServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator } from 'vs/base/common/decorators';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { isWindows } from 'vs/base/common/platform'; import { isWindows } from 'vs/base/common/platform';
...@@ -193,34 +192,3 @@ export class NoopLogService implements ILogService { ...@@ -193,34 +192,3 @@ export class NoopLogService implements ILogService {
critical(message: string | Error, ...args: any[]): void { } critical(message: string | Error, ...args: any[]): void { }
dispose(): void { } dispose(): void { }
} }
let globalLogService: ILogService = new NoopLogService();
export function registerGlobalLogService(logService: ILogService): void {
globalLogService = logService;
}
export function log(level: LogLevel, prefix: string, logFn?: (message: string, ...args: any[]) => string): Function {
return createDecorator((fn, key) => {
// TODO@Joao: load-time log level? return fn;
return function (this: any, ...args: any[]) {
let message = `${prefix} - ${key}`;
if (logFn) {
message = logFn(message, ...args);
}
switch (level) {
case LogLevel.Trace: globalLogService.trace(message); break;
case LogLevel.Debug: globalLogService.debug(message); break;
case LogLevel.Info: globalLogService.info(message); break;
case LogLevel.Warning: globalLogService.warn(message); break;
case LogLevel.Error: globalLogService.error(message); break;
case LogLevel.Critical: globalLogService.critical(message); break;
}
return fn.apply(this, args);
};
});
}
\ No newline at end of file
...@@ -58,6 +58,7 @@ import { ExtHostDecorations } from 'vs/workbench/api/node/extHostDecorations'; ...@@ -58,6 +58,7 @@ import { ExtHostDecorations } from 'vs/workbench/api/node/extHostDecorations';
import { toGlobPattern, toLanguageSelector } from 'vs/workbench/api/node/extHostTypeConverters'; import { toGlobPattern, toLanguageSelector } from 'vs/workbench/api/node/extHostTypeConverters';
import { ExtensionActivatedByAPI } from 'vs/workbench/api/node/extHostExtensionActivator'; import { ExtensionActivatedByAPI } from 'vs/workbench/api/node/extHostExtensionActivator';
import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
export interface IExtensionApiFactory { export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode; (extension: IExtensionDescription): typeof vscode;
...@@ -81,7 +82,8 @@ export function createApiFactory( ...@@ -81,7 +82,8 @@ export function createApiFactory(
threadService: ExtHostThreadService, threadService: ExtHostThreadService,
extHostWorkspace: ExtHostWorkspace, extHostWorkspace: ExtHostWorkspace,
extHostConfiguration: ExtHostConfiguration, extHostConfiguration: ExtHostConfiguration,
extensionService: ExtHostExtensionService extensionService: ExtHostExtensionService,
logService: ILogService
): IExtensionApiFactory { ): IExtensionApiFactory {
// Addressable instances // Addressable instances
...@@ -92,7 +94,7 @@ export function createApiFactory( ...@@ -92,7 +94,7 @@ export function createApiFactory(
const extHostDocumentContentProviders = threadService.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(threadService, extHostDocumentsAndEditors)); const extHostDocumentContentProviders = threadService.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(threadService, extHostDocumentsAndEditors));
const extHostDocumentSaveParticipant = threadService.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostDocuments, threadService.get(MainContext.MainThreadEditors))); const extHostDocumentSaveParticipant = threadService.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostDocuments, threadService.get(MainContext.MainThreadEditors)));
const extHostEditors = threadService.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(threadService, extHostDocumentsAndEditors)); const extHostEditors = threadService.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(threadService, extHostDocumentsAndEditors));
const extHostCommands = threadService.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(threadService, extHostHeapService)); const extHostCommands = threadService.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(threadService, extHostHeapService, logService));
const extHostTreeViews = threadService.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(threadService.get(MainContext.MainThreadTreeViews), extHostCommands)); const extHostTreeViews = threadService.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(threadService.get(MainContext.MainThreadTreeViews), extHostCommands));
threadService.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace); threadService.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace);
const extHostDebugService = threadService.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(threadService, extHostWorkspace)); const extHostDebugService = threadService.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(threadService, extHostWorkspace));
...@@ -103,7 +105,7 @@ export function createApiFactory( ...@@ -103,7 +105,7 @@ export function createApiFactory(
const extHostFileSystemEvent = threadService.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService()); const extHostFileSystemEvent = threadService.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService());
const extHostQuickOpen = threadService.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(threadService, extHostWorkspace, extHostCommands)); const extHostQuickOpen = threadService.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(threadService, extHostWorkspace, extHostCommands));
const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService)); const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService));
const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands)); const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands, logService));
const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace)); const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace));
const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService)); const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService));
threadService.set(ExtHostContext.ExtHostExtensionService, extensionService); threadService.set(ExtHostContext.ExtHostExtensionService, extensionService);
......
...@@ -15,7 +15,7 @@ import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; ...@@ -15,7 +15,7 @@ import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import * as modes from 'vs/editor/common/modes'; import * as modes from 'vs/editor/common/modes';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { log, LogLevel } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
interface CommandHandler { interface CommandHandler {
callback: Function; callback: Function;
...@@ -36,7 +36,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { ...@@ -36,7 +36,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
constructor( constructor(
mainContext: IMainContext, mainContext: IMainContext,
heapService: ExtHostHeapService heapService: ExtHostHeapService,
private logService: ILogService
) { ) {
this._proxy = mainContext.get(MainContext.MainThreadCommands); this._proxy = mainContext.get(MainContext.MainThreadCommands);
this._converter = new CommandsConverter(this, heapService); this._converter = new CommandsConverter(this, heapService);
...@@ -50,8 +51,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { ...@@ -50,8 +51,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
this._argumentProcessors.push(processor); this._argumentProcessors.push(processor);
} }
@log(LogLevel.Trace, 'ExtHostCommands', (msg, id) => `${msg}(${id})`)
registerCommand(id: string, callback: <T>(...args: any[]) => T | Thenable<T>, thisArg?: any, description?: ICommandHandlerDescription): extHostTypes.Disposable { registerCommand(id: string, callback: <T>(...args: any[]) => T | Thenable<T>, thisArg?: any, description?: ICommandHandlerDescription): extHostTypes.Disposable {
this.logService.trace('ExtHostCommands#registerCommand', id);
if (!id.trim().length) { if (!id.trim().length) {
throw new Error('invalid id'); throw new Error('invalid id');
...@@ -71,8 +72,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { ...@@ -71,8 +72,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
}); });
} }
@log(LogLevel.Trace, 'ExtHostCommands', (msg, id) => `${msg}(${id})`)
executeCommand<T>(id: string, ...args: any[]): Thenable<T> { executeCommand<T>(id: string, ...args: any[]): Thenable<T> {
this.logService.trace('ExtHostCommands#executeCommand', id);
if (this._commands.has(id)) { if (this._commands.has(id)) {
// we stay inside the extension host and support // we stay inside the extension host and support
...@@ -136,8 +137,9 @@ export class ExtHostCommands implements ExtHostCommandsShape { ...@@ -136,8 +137,9 @@ export class ExtHostCommands implements ExtHostCommandsShape {
} }
} }
@log(LogLevel.Trace, 'ExtHostCommands', (msg, filterUnderscoreCommands) => `${msg}(${filterUnderscoreCommands})`)
getCommands(filterUnderscoreCommands: boolean = false): Thenable<string[]> { getCommands(filterUnderscoreCommands: boolean = false): Thenable<string[]> {
this.logService.trace('ExtHostCommands#getCommands', filterUnderscoreCommands);
return this._proxy.$getCommands().then(result => { return this._proxy.$getCommands().then(result => {
if (filterUnderscoreCommands) { if (filterUnderscoreCommands) {
result = result.filter(command => command[0] !== '_'); result = result.filter(command => command[0] !== '_');
......
...@@ -21,6 +21,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; ...@@ -21,6 +21,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { realpath } from 'fs'; import { realpath } from 'fs';
import { TernarySearchTree } from 'vs/base/common/map'; import { TernarySearchTree } from 'vs/base/common/map';
import { Barrier } from 'vs/base/common/async'; import { Barrier } from 'vs/base/common/async';
import { ILogService } from 'vs/platform/log/common/log';
class ExtensionMemento implements IExtensionMemento { class ExtensionMemento implements IExtensionMemento {
...@@ -125,7 +126,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { ...@@ -125,7 +126,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
constructor(initData: IInitData, constructor(initData: IInitData,
threadService: ExtHostThreadService, threadService: ExtHostThreadService,
extHostWorkspace: ExtHostWorkspace, extHostWorkspace: ExtHostWorkspace,
extHostConfiguration: ExtHostConfiguration extHostConfiguration: ExtHostConfiguration,
logService: ILogService
) { ) {
this._barrier = new Barrier(); this._barrier = new Barrier();
this._registry = new ExtensionDescriptionRegistry(initData.extensions); this._registry = new ExtensionDescriptionRegistry(initData.extensions);
...@@ -137,7 +139,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { ...@@ -137,7 +139,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
this._activator = null; this._activator = null;
// initialize API first (i.e. do not release barrier until the API is initialized) // initialize API first (i.e. do not release barrier until the API is initialized)
const apiFactory = createApiFactory(initData, threadService, extHostWorkspace, extHostConfiguration, this); const apiFactory = createApiFactory(initData, threadService, extHostWorkspace, extHostConfiguration, this, logService);
initializeExtensionApi(this, apiFactory).then(() => { initializeExtensionApi(this, apiFactory).then(() => {
......
...@@ -17,7 +17,7 @@ import { sortedDiff } from 'vs/base/common/arrays'; ...@@ -17,7 +17,7 @@ import { sortedDiff } from 'vs/base/common/arrays';
import { comparePaths } from 'vs/base/common/comparers'; import { comparePaths } from 'vs/base/common/comparers';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { ISplice } from 'vs/base/common/sequence'; import { ISplice } from 'vs/base/common/sequence';
import { log, LogLevel } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
type ProviderHandle = number; type ProviderHandle = number;
type GroupHandle = number; type GroupHandle = number;
...@@ -444,7 +444,8 @@ export class ExtHostSCM { ...@@ -444,7 +444,8 @@ export class ExtHostSCM {
constructor( constructor(
mainContext: IMainContext, mainContext: IMainContext,
private _commands: ExtHostCommands private _commands: ExtHostCommands,
@ILogService private logService: ILogService
) { ) {
this._proxy = mainContext.get(MainContext.MainThreadSCM); this._proxy = mainContext.get(MainContext.MainThreadSCM);
...@@ -487,8 +488,9 @@ export class ExtHostSCM { ...@@ -487,8 +488,9 @@ export class ExtHostSCM {
}); });
} }
@log(LogLevel.Trace, 'ExtHostSCM', (msg, extension, id, label, rootUri) => `${msg}(${extension.id}, ${id}, ${label}, ${rootUri})`)
createSourceControl(extension: IExtensionDescription, id: string, label: string, rootUri: vscode.Uri | undefined): vscode.SourceControl { createSourceControl(extension: IExtensionDescription, id: string, label: string, rootUri: vscode.Uri | undefined): vscode.SourceControl {
this.logService.trace('ExtHostSCM#createSourceControl', extension.id, id, label, rootUri);
const handle = ExtHostSCM._handlePool++; const handle = ExtHostSCM._handlePool++;
const sourceControl = new ExtHostSourceControl(this._proxy, this._commands, id, label, rootUri); const sourceControl = new ExtHostSourceControl(this._proxy, this._commands, id, label, rootUri);
this._sourceControls.set(handle, sourceControl); this._sourceControls.set(handle, sourceControl);
...@@ -501,8 +503,9 @@ export class ExtHostSCM { ...@@ -501,8 +503,9 @@ export class ExtHostSCM {
} }
// Deprecated // Deprecated
@log(LogLevel.Trace, 'ExtHostSCM', (msg, extension) => `${msg}(${extension.id})`)
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox { getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox {
this.logService.trace('ExtHostSCM#getLastInputBox', extension.id);
const sourceControls = this._sourceControlsByExtension.get(extension.id); const sourceControls = this._sourceControlsByExtension.get(extension.id);
const sourceControl = sourceControls && sourceControls[sourceControls.length - 1]; const sourceControl = sourceControls && sourceControls[sourceControls.length - 1];
const inputBox = sourceControl && sourceControl.inputBox; const inputBox = sourceControl && sourceControl.inputBox;
...@@ -510,8 +513,9 @@ export class ExtHostSCM { ...@@ -510,8 +513,9 @@ export class ExtHostSCM {
return inputBox; return inputBox;
} }
@log(LogLevel.Trace, 'ExtHostSCM', (msg, handle, uri) => `${msg}(${handle}, ${uri})`)
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI> { $provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI> {
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, uri);
const sourceControl = this._sourceControls.get(sourceControlHandle); const sourceControl = this._sourceControls.get(sourceControlHandle);
if (!sourceControl || !sourceControl.quickDiffProvider) { if (!sourceControl || !sourceControl.quickDiffProvider) {
...@@ -524,8 +528,9 @@ export class ExtHostSCM { ...@@ -524,8 +528,9 @@ export class ExtHostSCM {
}); });
} }
@log(LogLevel.Trace, 'ExtHostSCM', (msg, handle) => `${msg}(${handle})`)
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> { $onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> {
this.logService.trace('ExtHostSCM#$onInputBoxValueChange', sourceControlHandle);
const sourceControl = this._sourceControls.get(sourceControlHandle); const sourceControl = this._sourceControls.get(sourceControlHandle);
if (!sourceControl) { if (!sourceControl) {
...@@ -536,8 +541,9 @@ export class ExtHostSCM { ...@@ -536,8 +541,9 @@ export class ExtHostSCM {
return TPromise.as(null); return TPromise.as(null);
} }
@log(LogLevel.Trace, 'ExtHostSCM', (msg, h1, h2, h3) => `${msg}(${h1}, ${h2}, ${h3})`)
async $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void> { async $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void> {
this.logService.trace('ExtHostSCM#$executeResourceCommand', sourceControlHandle, groupHandle, handle);
const sourceControl = this._sourceControls.get(sourceControlHandle); const sourceControl = this._sourceControls.get(sourceControlHandle);
if (!sourceControl) { if (!sourceControl) {
......
...@@ -42,7 +42,6 @@ import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; ...@@ -42,7 +42,6 @@ import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { createLogService } from 'vs/platform/log/node/spdlogService'; import { createLogService } from 'vs/platform/log/node/spdlogService';
import fs = require('fs'); import fs = require('fs');
import { registerGlobalLogService } from 'vs/platform/log/common/log';
gracefulFs.gracefulify(fs); // enable gracefulFs gracefulFs.gracefulify(fs); // enable gracefulFs
const currentWindowId = remote.getCurrentWindow().id; const currentWindowId = remote.getCurrentWindow().id;
...@@ -75,7 +74,6 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> { ...@@ -75,7 +74,6 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const environmentService = new EnvironmentService(configuration, configuration.execPath); const environmentService = new EnvironmentService(configuration, configuration.execPath);
const logService = createLogService(`renderer${currentWindowId}`, environmentService); const logService = createLogService(`renderer${currentWindowId}`, environmentService);
registerGlobalLogService(logService);
logService.info('openWorkbench', JSON.stringify(configuration)); logService.info('openWorkbench', JSON.stringify(configuration));
......
...@@ -24,7 +24,6 @@ import * as glob from 'vs/base/common/glob'; ...@@ -24,7 +24,6 @@ import * as glob from 'vs/base/common/glob';
import { ExtensionActivatedByEvent } from 'vs/workbench/api/node/extHostExtensionActivator'; import { ExtensionActivatedByEvent } from 'vs/workbench/api/node/extHostExtensionActivator';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { createLogService } from 'vs/platform/log/node/spdlogService'; import { createLogService } from 'vs/platform/log/node/spdlogService';
import { registerGlobalLogService } from 'vs/platform/log/common/log';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
// const nativeExit = process.exit.bind(process); // const nativeExit = process.exit.bind(process);
...@@ -91,15 +90,13 @@ export class ExtensionHostMain { ...@@ -91,15 +90,13 @@ export class ExtensionHostMain {
const extHostWorkspace = new ExtHostWorkspace(threadService, initData.workspace); const extHostWorkspace = new ExtHostWorkspace(threadService, initData.workspace);
const environmentService = new EnvironmentService(initData.args, initData.execPath); const environmentService = new EnvironmentService(initData.args, initData.execPath);
const logService = createLogService(`exthost${initData.windowId}`, environmentService); const logService = createLogService(`exthost${initData.windowId}`, environmentService);
registerGlobalLogService(logService);
this.disposables.push(logService); this.disposables.push(logService);
logService.info('extension host started'); logService.info('extension host started');
logService.trace('initData', initData); logService.trace('initData', initData);
this._extHostConfiguration = new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration); this._extHostConfiguration = new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration);
this._extensionService = new ExtHostExtensionService(initData, threadService, extHostWorkspace, this._extHostConfiguration); this._extensionService = new ExtHostExtensionService(initData, threadService, extHostWorkspace, this._extHostConfiguration, logService);
// error forwarding and stack trace scanning // error forwarding and stack trace scanning
const extensionErrors = new WeakMap<Error, IExtensionDescription>(); const extensionErrors = new WeakMap<Error, IExtensionDescription>();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository } from './scm'; import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository } from './scm';
import { log, LogLevel } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
class SCMInput implements ISCMInput { class SCMInput implements ISCMInput {
...@@ -77,8 +77,11 @@ export class SCMService implements ISCMService { ...@@ -77,8 +77,11 @@ export class SCMService implements ISCMService {
private _onDidRemoveProvider = new Emitter<ISCMRepository>(); private _onDidRemoveProvider = new Emitter<ISCMRepository>();
get onDidRemoveRepository(): Event<ISCMRepository> { return this._onDidRemoveProvider.event; } get onDidRemoveRepository(): Event<ISCMRepository> { return this._onDidRemoveProvider.event; }
@log(LogLevel.Info, 'SCMService') constructor( @ILogService private logService: ILogService) { }
registerSCMProvider(provider: ISCMProvider): ISCMRepository { registerSCMProvider(provider: ISCMProvider): ISCMRepository {
this.logService.info('SCMService#registerSCMProvider');
if (this._providerIds.has(provider.id)) { if (this._providerIds.has(provider.id)) {
throw new Error(`SCM Provider ${provider.id} already exists.`); throw new Error(`SCM Provider ${provider.id} already exists.`);
} }
......
...@@ -32,6 +32,7 @@ import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; ...@@ -32,6 +32,7 @@ import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import 'vs/workbench/parts/search/electron-browser/search.contribution'; import 'vs/workbench/parts/search/electron-browser/search.contribution';
import { NoopLogService } from 'vs/platform/log/common/log';
const defaultSelector = { scheme: 'far' }; const defaultSelector = { scheme: 'far' };
const model: EditorCommon.IModel = EditorModel.createFromString( const model: EditorCommon.IModel = EditorModel.createFromString(
...@@ -113,7 +114,7 @@ suite('ExtHostLanguageFeatureCommands', function () { ...@@ -113,7 +114,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
const heapService = new ExtHostHeapService(); const heapService = new ExtHostHeapService();
commands = new ExtHostCommands(threadService, heapService); commands = new ExtHostCommands(threadService, heapService, new NoopLogService());
threadService.set(ExtHostContext.ExtHostCommands, commands); threadService.set(ExtHostContext.ExtHostCommands, commands);
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
ExtHostApiCommands.register(commands); ExtHostApiCommands.register(commands);
......
...@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { OneGetThreadService } from './testThreadService'; import { OneGetThreadService } from './testThreadService';
import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { NoopLogService } from 'vs/platform/log/common/log';
suite('ExtHostCommands', function () { suite('ExtHostCommands', function () {
...@@ -29,7 +30,7 @@ suite('ExtHostCommands', function () { ...@@ -29,7 +30,7 @@ suite('ExtHostCommands', function () {
} }
}; };
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined); const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
commands.registerCommand('foo', (): any => { }).dispose(); commands.registerCommand('foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo'); assert.equal(lastUnregister, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined); assert.equal(CommandsRegistry.getCommand('foo'), undefined);
...@@ -50,7 +51,7 @@ suite('ExtHostCommands', function () { ...@@ -50,7 +51,7 @@ suite('ExtHostCommands', function () {
} }
}; };
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined); const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
const reg = commands.registerCommand('foo', (): any => { }); const reg = commands.registerCommand('foo', (): any => { });
reg.dispose(); reg.dispose();
reg.dispose(); reg.dispose();
......
...@@ -44,6 +44,7 @@ import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics'; ...@@ -44,6 +44,7 @@ import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService'; import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NoopLogService } from 'vs/platform/log/common/log';
const defaultSelector = { scheme: 'far' }; const defaultSelector = { scheme: 'far' };
const model: EditorCommon.IModel = EditorModel.createFromString( const model: EditorCommon.IModel = EditorModel.createFromString(
...@@ -102,7 +103,7 @@ suite('ExtHostLanguageFeatures', function () { ...@@ -102,7 +103,7 @@ suite('ExtHostLanguageFeatures', function () {
const heapService = new ExtHostHeapService(); const heapService = new ExtHostHeapService();
const commands = new ExtHostCommands(threadService, heapService); const commands = new ExtHostCommands(threadService, heapService, new NoopLogService());
threadService.set(ExtHostContext.ExtHostCommands, commands); threadService.set(ExtHostContext.ExtHostCommands, commands);
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
......
...@@ -19,6 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -19,6 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views'; import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views';
import { NoopLogService } from 'vs/platform/log/common/log';
suite('ExtHostTreeView', function () { suite('ExtHostTreeView', function () {
...@@ -65,7 +66,7 @@ suite('ExtHostTreeView', function () { ...@@ -65,7 +66,7 @@ suite('ExtHostTreeView', function () {
threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService)); threadService.setTestInstance(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, threadService));
target = new RecordingShape(); target = new RecordingShape();
testObject = new ExtHostTreeViews(target, new ExtHostCommands(threadService, new ExtHostHeapService())); testObject = new ExtHostTreeViews(target, new ExtHostCommands(threadService, new ExtHostHeapService(), new NoopLogService()));
onDidChangeTreeNode = new Emitter<{ key: string }>(); onDidChangeTreeNode = new Emitter<{ key: string }>();
onDidChangeTreeKey = new Emitter<string>(); onDidChangeTreeKey = new Emitter<string>();
testObject.registerTreeDataProvider('testNodeTreeProvider', aNodeTreeDataProvider()); testObject.registerTreeDataProvider('testNodeTreeProvider', aNodeTreeDataProvider());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册