mirror of
https://github.com/coder/code-server.git
synced 2026-06-21 17:37:11 +02:00
chore(vscode): update to 1.56.0
This commit is contained in:
@@ -82,7 +82,7 @@ export class BufferLogService extends AbstractLogger implements ILogService {
|
||||
this._log(LogLevel.Critical, message, ...args);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
if (this._logger) {
|
||||
this._logger.dispose();
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ILogService, LogLevel, AbstractLogger, ILoggerService, ILogger } from 'vs/platform/log/common/log';
|
||||
import { ILogService, LogLevel, AbstractLogger, ILoggerService, ILogger, AbstractLoggerService } from 'vs/platform/log/common/log';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ByteSize, FileOperationError, FileOperationResult, IFileService, whenProviderRegistered } 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';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { BufferLogService } from 'vs/platform/log/common/bufferLog';
|
||||
|
||||
@@ -159,34 +158,19 @@ export class FileLogger extends AbstractLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
export class FileLoggerService extends Disposable implements ILoggerService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly loggers = new Map<string, ILogger>();
|
||||
export class FileLoggerService extends AbstractLoggerService implements ILoggerService {
|
||||
|
||||
constructor(
|
||||
@ILogService private logService: ILogService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@ILogService logService: ILogService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
) {
|
||||
super();
|
||||
this._register(logService.onDidChangeLogLevel(level => this.loggers.forEach(logger => logger.setLevel(level))));
|
||||
super(logService.getLevel(), logService.onDidChangeLogLevel);
|
||||
}
|
||||
|
||||
createLogger(resource: URI): ILogger {
|
||||
let logger = this.loggers.get(resource.toString());
|
||||
if (!logger) {
|
||||
logger = new BufferLogService(this.logService.getLevel());
|
||||
this.loggers.set(resource.toString(), logger);
|
||||
whenProviderRegistered(resource, this.fileService).then(() => (<BufferLogService>logger).logger = this.instantiationService.createInstance(FileLogger, basename(resource), resource, this.logService.getLevel()));
|
||||
}
|
||||
protected doCreateLogger(resource: URI, logLevel: LogLevel): ILogger {
|
||||
const logger = new BufferLogService(logLevel);
|
||||
whenProviderRegistered(resource, this.fileService).then(() => (<BufferLogService>logger).logger = this.instantiationService.createInstance(FileLogger, basename(resource), resource, logger.getLevel()));
|
||||
return logger;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.loggers.forEach(logger => logger.dispose());
|
||||
this.loggers.clear();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ export class ConsoleMainLogger extends AbstractLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ export class ConsoleLogger extends AbstractLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ export class AdapterLogger extends AbstractLogger implements ILogger {
|
||||
return toErrorMessage(msg, this.getLevel() <= LogLevel.Trace);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ export class MultiplexLogService extends AbstractLogger implements ILogService {
|
||||
}
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
override setLevel(level: LogLevel): void {
|
||||
for (const logService of this.logServices) {
|
||||
logService.setLevel(level);
|
||||
}
|
||||
@@ -431,7 +431,7 @@ export class MultiplexLogService extends AbstractLogger implements ILogService {
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
for (const logService of this.logServices) {
|
||||
logService.dispose();
|
||||
}
|
||||
@@ -487,6 +487,46 @@ export class LogService extends Disposable implements ILogService {
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class AbstractLoggerService extends Disposable implements ILoggerService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly loggers = new Map<string, ILogger>();
|
||||
private readonly logLevelChangeableLoggers: ILogger[] = [];
|
||||
|
||||
constructor(
|
||||
private logLevel: LogLevel,
|
||||
onDidChangeLogLevel: Event<LogLevel>,
|
||||
) {
|
||||
super();
|
||||
this._register(onDidChangeLogLevel(logLevel => {
|
||||
this.logLevel = logLevel;
|
||||
this.logLevelChangeableLoggers.forEach(logger => logger.setLevel(logLevel));
|
||||
}));
|
||||
}
|
||||
|
||||
createLogger(resource: URI, options?: ILoggerOptions): ILogger {
|
||||
let logger = this.loggers.get(resource.toString());
|
||||
if (!logger) {
|
||||
logger = this.doCreateLogger(resource, options?.always ? LogLevel.Trace : this.logLevel, options);
|
||||
this.loggers.set(resource.toString(), logger);
|
||||
if (!options?.always) {
|
||||
this.logLevelChangeableLoggers.push(logger);
|
||||
}
|
||||
}
|
||||
return logger;
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
this.logLevelChangeableLoggers.splice(0, this.logLevelChangeableLoggers.length);
|
||||
this.loggers.forEach(logger => logger.dispose());
|
||||
this.loggers.clear();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected abstract doCreateLogger(resource: URI, logLevel: LogLevel, options?: ILoggerOptions): ILogger;
|
||||
}
|
||||
|
||||
export class NullLogService implements ILogService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
readonly onDidChangeLogLevel: Event<LogLevel> = new Emitter<LogLevel>().event;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { LogLevel, ILogService, LogService, ILoggerService, ILogger, AbstractMessageLogger, ILoggerOptions, AdapterLogger } from 'vs/platform/log/common/log';
|
||||
import { LogLevel, ILogService, LogService, ILoggerService, ILogger, AbstractMessageLogger, ILoggerOptions, AdapterLogger, AbstractLoggerService } from 'vs/platform/log/common/log';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -113,11 +113,11 @@ export class LoggerChannel implements IServerChannel {
|
||||
}
|
||||
}
|
||||
|
||||
export class LoggerChannelClient implements ILoggerService {
|
||||
export class LoggerChannelClient extends AbstractLoggerService implements ILoggerService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor(private readonly channel: IChannel) { }
|
||||
constructor(logLevel: LogLevel, onDidChangeLogLevel: Event<LogLevel>, private readonly channel: IChannel) {
|
||||
super(logLevel, onDidChangeLogLevel);
|
||||
}
|
||||
|
||||
createConsoleMainLogger(): ILogger {
|
||||
return new AdapterLogger({
|
||||
@@ -127,8 +127,8 @@ export class LoggerChannelClient implements ILoggerService {
|
||||
});
|
||||
}
|
||||
|
||||
createLogger(file: URI, options?: ILoggerOptions): ILogger {
|
||||
return new Logger(this.channel, file, options);
|
||||
protected doCreateLogger(file: URI, logLevel: LogLevel, options?: ILoggerOptions): ILogger {
|
||||
return new Logger(this.channel, file, logLevel, options);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,38 +141,40 @@ class Logger extends AbstractMessageLogger {
|
||||
constructor(
|
||||
private readonly channel: IChannel,
|
||||
private readonly file: URI,
|
||||
logLevel: LogLevel,
|
||||
loggerOptions?: ILoggerOptions,
|
||||
) {
|
||||
super(loggerOptions?.always);
|
||||
this.setLevel(logLevel);
|
||||
this.channel.call('createLogger', [file, loggerOptions])
|
||||
.then(() => {
|
||||
this._log(this.buffer);
|
||||
this.doLog(this.buffer);
|
||||
this.isLoggerCreated = true;
|
||||
});
|
||||
}
|
||||
|
||||
protected log(level: LogLevel, message: string) {
|
||||
this._log([[level, message]]);
|
||||
}
|
||||
|
||||
private _log(messages: [LogLevel, string][]) {
|
||||
const messages: [LogLevel, string][] = [[level, message]];
|
||||
if (this.isLoggerCreated) {
|
||||
this.channel.call('log', [this.file, messages]);
|
||||
this.doLog(messages);
|
||||
} else {
|
||||
this.buffer.push(...messages);
|
||||
}
|
||||
}
|
||||
|
||||
private doLog(messages: [LogLevel, string][]) {
|
||||
this.channel.call('log', [this.file, messages]);
|
||||
}
|
||||
}
|
||||
|
||||
export class FollowerLogService extends LogService implements ILogService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor(private parent: LogLevelChannelClient, logService: ILogService) {
|
||||
super(logService);
|
||||
this._register(parent.onDidChangeLogLevel(level => logService.setLevel(level)));
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
override setLevel(level: LogLevel): void {
|
||||
super.setLevel(level);
|
||||
|
||||
this.parent.setLevel(level);
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ILogService, ILoggerService, ILogger, ILoggerOptions, LogLevel } from 'vs/platform/log/common/log';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ILogService, ILoggerService, ILogger, ILoggerOptions, AbstractLoggerService, LogLevel } from 'vs/platform/log/common/log';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
@@ -13,47 +12,25 @@ import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
export class LoggerService extends Disposable implements ILoggerService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly loggers = new Map<string, ILogger>();
|
||||
private readonly logLevelChangeableLoggers: ILogger[] = [];
|
||||
export class LoggerService extends AbstractLoggerService implements ILoggerService {
|
||||
|
||||
constructor(
|
||||
@ILogService private logService: ILogService,
|
||||
@IFileService private fileService: IFileService
|
||||
@ILogService logService: ILogService,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
) {
|
||||
super();
|
||||
this._register(logService.onDidChangeLogLevel(level => this.logLevelChangeableLoggers.forEach(logger => logger.setLevel(level))));
|
||||
super(logService.getLevel(), logService.onDidChangeLogLevel);
|
||||
}
|
||||
|
||||
createLogger(resource: URI, options?: ILoggerOptions): ILogger {
|
||||
let logger = this.loggers.get(resource.toString());
|
||||
if (!logger) {
|
||||
if (resource.scheme === Schemas.file) {
|
||||
logger = new SpdLogLogger(options?.name || generateUuid(), resource.fsPath, !options?.donotRotate, this.logService.getLevel());
|
||||
if (options?.donotUseFormatters) {
|
||||
(<SpdLogLogger>logger).clearFormatters();
|
||||
}
|
||||
} else {
|
||||
logger = new FileLogger(options?.name ?? basename(resource), resource, this.logService.getLevel(), this.fileService);
|
||||
}
|
||||
this.loggers.set(resource.toString(), logger);
|
||||
if (options?.always) {
|
||||
logger.setLevel(LogLevel.Trace);
|
||||
} else {
|
||||
this.logLevelChangeableLoggers.push(logger);
|
||||
protected doCreateLogger(resource: URI, logLevel: LogLevel, options?: ILoggerOptions): ILogger {
|
||||
if (resource.scheme === Schemas.file) {
|
||||
const logger = new SpdLogLogger(options?.name || generateUuid(), resource.fsPath, !options?.donotRotate, logLevel);
|
||||
if (options?.donotUseFormatters) {
|
||||
(<SpdLogLogger>logger).clearFormatters();
|
||||
}
|
||||
return logger;
|
||||
} else {
|
||||
return new FileLogger(options?.name ?? basename(resource), resource, logLevel, this.fileService);
|
||||
}
|
||||
return logger;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.logLevelChangeableLoggers.splice(0, this.logLevelChangeableLoggers.length);
|
||||
this.loggers.forEach(logger => logger.dispose());
|
||||
this.loggers.clear();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ export class SpdLogLogger extends AbstractMessageLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
flush(): void {
|
||||
override flush(): void {
|
||||
if (this._logger) {
|
||||
this._logger.flush();
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ export class SpdLogLogger extends AbstractMessageLogger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
if (this._logger) {
|
||||
this.disposeLogger();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user