Skip to content

Commit

Permalink
fixes #39577
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Dec 7, 2017
1 parent f3610b7 commit c107a5e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/commands/common/commandService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CommandService extends Disposable implements ICommandService {
}

executeCommand<T>(id: string, ...args: any[]): TPromise<T> {
this._logService.info('CommandService#executeCommand', id);
this._logService.trace('CommandService#executeCommand', id);

// we always send an activation event, but
// we don't wait for it when the extension
Expand Down
56 changes: 56 additions & 0 deletions src/vs/platform/log/common/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,62 @@ export class ConsoleLogMainService implements ILogService {
}
}

export class ConsoleLogService implements ILogService {

_serviceBrand: any;
private level: LogLevel = LogLevel.Error;

constructor( @IEnvironmentService environmentService: IEnvironmentService) {
this.setLevel(environmentService.logLevel);
}

setLevel(level: LogLevel): void {
this.level = level;
}

getLevel(): LogLevel {
return this.level;
}

trace(message: string, ...args: any[]): void {
if (this.level <= LogLevel.Trace) {
console.log('%cTRACE', 'color: #888', message, ...args);
}
}

debug(message: string, ...args: any[]): void {
if (this.level <= LogLevel.Debug) {
console.log('%cDEBUG', 'background: #eee; color: #888', message, ...args);
}
}

info(message: string, ...args: any[]): void {
if (this.level <= LogLevel.Info) {
console.log('%c INFO', 'color: #33f', message, ...args);
}
}

warn(message: string | Error, ...args: any[]): void {
if (this.level <= LogLevel.Warning) {
console.log('%c WARN', 'color: #993', message, ...args);
}
}

error(message: string, ...args: any[]): void {
if (this.level <= LogLevel.Error) {
console.log('%c ERR', 'color: #f33', message, ...args);
}
}

critical(message: string, ...args: any[]): void {
if (this.level <= LogLevel.Critical) {
console.log('%cCRITI', 'background: #f33; color: white', message, ...args);
}
}

dispose(): void { }
}

export class MultiplexLogService implements ILogService {
_serviceBrand: any;

Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/electron-browser/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { createLogService } from 'vs/platform/log/node/spdlogService';

import fs = require('fs');
import { ConsoleLogService, MultiplexLogService } from 'vs/platform/log/common/log';
gracefulFs.gracefulify(fs); // enable gracefulFs

const currentWindowId = remote.getCurrentWindow().id;
Expand Down Expand Up @@ -73,9 +74,12 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const mainServices = createMainProcessServices(mainProcessClient);

const environmentService = new EnvironmentService(configuration, configuration.execPath);
const logService = createLogService(`renderer${currentWindowId}`, environmentService);
const spdlogService = createLogService(`renderer${currentWindowId}`, environmentService);
const consoleLogService = new ConsoleLogService(environmentService);
const logService = new MultiplexLogService([consoleLogService, spdlogService]);

logService.info('openWorkbench', JSON.stringify(configuration));
logService.info('openWorkbench');
logService.trace('openWorkbench configuration', JSON.stringify(configuration));

// Since the configuration service is one of the core services that is used in so many places, we initialize it
// right before startup of the workbench shell to have its data ready for consumers
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/services/scm/common/scmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class SCMService implements ISCMService {
constructor( @ILogService private logService: ILogService) { }

registerSCMProvider(provider: ISCMProvider): ISCMRepository {
this.logService.info('SCMService#registerSCMProvider');
this.logService.trace('SCMService#registerSCMProvider');

if (this._providerIds.has(provider.id)) {
throw new Error(`SCM Provider ${provider.id} already exists.`);
Expand Down

0 comments on commit c107a5e

Please sign in to comment.