Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. 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;
@@ -24,12 +24,13 @@ function getLogFunction(logger: ILogService, level: LogLevel): Function {
export class BufferLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
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);
@@ -86,4 +87,4 @@ export class BufferLogService extends AbstractLogService implements ILogService
this._logger.dispose();
}
}
}
}

View File

@@ -8,12 +8,16 @@ import { URI } from 'vs/base/common/uri';
import { IFileService } from 'vs/platform/files/common/files';
import { Queue } from 'vs/base/common/async';
import { VSBuffer } from 'vs/base/common/buffer';
import { dirname, joinPath, basename } from 'vs/base/common/resources';
const MAX_FILE_SIZE = 1024 * 1024 * 5;
export class FileLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
private readonly queue: Queue<void>;
private backupIndex: number = 1;
constructor(
private readonly name: string,
@@ -81,6 +85,10 @@ export class FileLogService extends AbstractLogService implements ILogService {
private _log(level: LogLevel, message: string): void {
this.queue.queue(async () => {
let content = await this.loadContent();
if (content.length > MAX_FILE_SIZE) {
await this.fileService.writeFile(this.getBackupResource(), VSBuffer.fromString(content));
content = '';
}
content += `[${this.getCurrentTimestamp()}] [${this.name}] [${this.stringifyLogLevel(level)}] ${message}\n`;
await this.fileService.writeFile(this.resource, VSBuffer.fromString(content));
});
@@ -93,6 +101,11 @@ export class FileLogService extends AbstractLogService implements ILogService {
return `${currentTime.getFullYear()}-${toTwoDigits(currentTime.getMonth() + 1)}-${toTwoDigits(currentTime.getDate())} ${toTwoDigits(currentTime.getHours())}:${toTwoDigits(currentTime.getMinutes())}:${toTwoDigits(currentTime.getSeconds())}.${toThreeDigits(currentTime.getMilliseconds())}`;
}
private getBackupResource(): URI {
this.backupIndex = this.backupIndex > 5 ? 1 : this.backupIndex;
return joinPath(dirname(this.resource), `${basename(this.resource)}_${this.backupIndex++}`);
}
private async loadContent(): Promise<string> {
try {
const content = await this.fileService.readFile(this.resource);

View File

@@ -28,7 +28,7 @@ export enum LogLevel {
export const DEFAULT_LOG_LEVEL: LogLevel = LogLevel.Info;
export interface ILogService extends IDisposable {
_serviceBrand: any;
_serviceBrand: undefined;
onDidChangeLogLevel: Event<LogLevel>;
getLevel(): LogLevel;
@@ -61,7 +61,7 @@ export abstract class AbstractLogService extends Disposable {
export class ConsoleLogMainService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
private useColors: boolean;
constructor(logLevel: LogLevel = DEFAULT_LOG_LEVEL) {
@@ -137,7 +137,7 @@ export class ConsoleLogMainService extends AbstractLogService implements ILogSer
export class ConsoleLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
constructor(logLevel: LogLevel = DEFAULT_LOG_LEVEL) {
super();
@@ -184,7 +184,7 @@ export class ConsoleLogService extends AbstractLogService implements ILogService
}
export class MultiplexLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
constructor(private readonly logServices: ReadonlyArray<ILogService>) {
super();
@@ -244,7 +244,7 @@ export class MultiplexLogService extends AbstractLogService implements ILogServi
}
export class DelegatedLogService extends Disposable implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
constructor(private logService: ILogService) {
super();
@@ -289,7 +289,7 @@ export class DelegatedLogService extends Disposable implements ILogService {
}
export class NullLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
readonly onDidChangeLogLevel: Event<LogLevel> = new Emitter<LogLevel>().event;
setLevel(level: LogLevel): void { }
getLevel(): LogLevel { return LogLevel.Info; }

View File

@@ -46,7 +46,7 @@ export class LogLevelSetterChannelClient {
}
export class FollowerLogService extends DelegatedLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
constructor(private master: LogLevelSetterChannelClient, logService: ILogService) {
super(logService);

View File

@@ -44,7 +44,7 @@ function log(logger: spdlog.RotatingLogger, level: LogLevel, message: string): v
export class SpdLogService extends AbstractLogService implements ILogService {
_serviceBrand: any;
_serviceBrand: undefined;
private buffer: ILog[] = [];
private _loggerCreationPromise: Promise<void> | undefined = undefined;