Merge branch 'master' into sandy081/outputChannel

This commit is contained in:
Sandeep Somavarapu
2018-09-21 10:15:35 +02:00
843 changed files with 18519 additions and 10988 deletions

View File

@@ -18,10 +18,10 @@ export abstract class AbstractExtHostOutputChannel implements vscode.OutputChann
protected readonly _proxy: MainThreadOutputServiceShape;
private _disposed: boolean;
constructor(name: string, file: URI, proxy: MainThreadOutputServiceShape) {
constructor(name: string, log: boolean, file: URI, proxy: MainThreadOutputServiceShape) {
this._name = name;
this._proxy = proxy;
this._id = proxy.$register(this.name, file);
this._id = proxy.$register(this.name, log, file);
}
get name(): string {
@@ -68,7 +68,7 @@ export abstract class AbstractExtHostOutputChannel implements vscode.OutputChann
export class ExtHostPushOutputChannel extends AbstractExtHostOutputChannel {
constructor(name: string, proxy: MainThreadOutputServiceShape) {
super(name, null, proxy);
super(name, false, null, proxy);
}
append(value: string): void {
@@ -77,16 +77,16 @@ export class ExtHostPushOutputChannel extends AbstractExtHostOutputChannel {
}
}
export class ExtHostPullOutputChannel extends AbstractExtHostOutputChannel {
export class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChannel {
private static _namePool = 1;
private _appender: OutputAppender;
constructor(name: string, outputDir: string, proxy: MainThreadOutputServiceShape) {
const fileName = `${ExtHostPullOutputChannel._namePool++}-${name}`;
const fileName = `${ExtHostOutputChannelBackedByFile._namePool++}-${name}`;
const file = URI.file(posix.join(outputDir, `${fileName}.log`));
super(name, file, proxy);
super(name, false, file, proxy);
this._appender = new OutputAppender(fileName, file.fsPath);
}
@@ -96,6 +96,17 @@ export class ExtHostPullOutputChannel extends AbstractExtHostOutputChannel {
}
}
export class ExtHostLogFileOutputChannel extends AbstractExtHostOutputChannel {
constructor(name: string, file: URI, proxy: MainThreadOutputServiceShape) {
super(name, true, file, proxy);
}
append(value: string): void {
throw new Error('Not supported');
}
}
export class ExtHostOutputService {
private _proxy: MainThreadOutputServiceShape;
@@ -111,7 +122,28 @@ export class ExtHostOutputService {
if (!name) {
throw new Error('illegal argument `name`. must not be falsy');
} else {
return options && options.force ? new ExtHostPushOutputChannel(name, this._proxy) : new ExtHostPullOutputChannel(name, this._outputDir, this._proxy);
if (options && options.force) {
return new ExtHostPushOutputChannel(name, this._proxy);
} else {
// Do not crash if logger cannot be created
try {
return new ExtHostOutputChannelBackedByFile(name, this._outputDir, this._proxy);
} catch (error) {
console.log(error);
return new ExtHostPushOutputChannel(name, this._proxy);
}
}
}
}
createOutputChannelFromLogFile(name: string, file: URI): vscode.OutputChannel {
name = name.trim();
if (!name) {
throw new Error('illegal argument `name`. must not be falsy');
}
if (!file) {
throw new Error('illegal argument `file`. must not be falsy');
}
return new ExtHostLogFileOutputChannel(name, file, this._proxy);
}
}