Skip to content

Commit

Permalink
Persist log level change in web
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Sep 2, 2019
1 parent b8d5f4c commit 31857fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/vs/platform/log/common/bufferLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ILogService, LogLevel, AbstractLogService } from 'vs/platform/log/common/log';
import { ILogService, LogLevel, AbstractLogService, DEFAULT_LOG_LEVEL } from 'vs/platform/log/common/log';

interface ILog {
level: LogLevel;
Expand All @@ -28,8 +28,9 @@ export class BufferLogService extends AbstractLogService implements ILogService
private buffer: ILog[] = [];
private _logger: ILogService | undefined = undefined;

constructor() {
constructor(logLevel: LogLevel = DEFAULT_LOG_LEVEL) {
super();
this.setLevel(logLevel);
this._register(this.onDidChangeLogLevel(level => {
if (this._logger) {
this._logger.setLevel(level);
Expand Down Expand Up @@ -86,4 +87,4 @@ export class BufferLogService extends AbstractLogService implements ILogService
this._logger.dispose();
}
}
}
}
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/web.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CodeRendererMain extends Disposable {

// Log
const logsPath = URI.file(toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '')).with({ scheme: 'vscode-log' });
const logService = new BufferLogService();
const logService = new BufferLogService(this.configuration.logLevel);
serviceCollection.set(ILogService, logService);

const payload = this.resolveWorkspaceInitializationPayload();
Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/workbench.web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ICredentialsProvider } from 'vs/workbench/services/credentials/browser/
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IURLCallbackProvider } from 'vs/workbench/services/url/browser/urlService';
import { IProductConfiguration } from 'vs/platform/product/common/product';
import { LogLevel } from 'vs/platform/log/common/log';

export interface IWorkbenchConstructionOptions {

Expand Down Expand Up @@ -77,6 +78,11 @@ export interface IWorkbenchConstructionOptions {
* Experimental: Support for product configuration.
*/
productConfiguration?: IProductConfiguration;

/**
* Current logging level. Default is `LogLevel.Info`.
*/
logLevel?: LogLevel;
}

/**
Expand Down

0 comments on commit 31857fa

Please sign in to comment.