Skip to content

Commit

Permalink
#39807 Adopt the rotating file format change in output panel
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 26, 2018
1 parent 59ec992 commit 6266e0f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/vs/workbench/parts/output/electron-browser/outputServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,23 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
private appendedMessage = '';
private loadingFromFileInProgress: boolean = false;
private resettingDelayer: ThrottledDelayer<void>;
private readonly rotatingFilePath: string;

constructor(
outputChannelIdentifier: IOutputChannelIdentifier,
outputDir: string,
modelUri: URI,
@IFileService fileService: IFileService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@ILogService logService: ILogService
) {
super(outputChannelIdentifier, modelUri, fileService, modelService, modeService);
super({ ...outputChannelIdentifier, file: URI.file(paths.join(outputDir, `${outputChannelIdentifier.id}.log`)) }, modelUri, fileService, modelService, modeService);

// Use one rotating file to check for main file reset
this.outputWriter = new RotatingLogger(this.id, this.file.fsPath, 1024 * 1024 * 30, 1);
this.outputWriter.clearFormatters();
this.rotatingFilePath = `${outputChannelIdentifier.id}.1.log`;
this._register(watchOutputDirectory(paths.dirname(this.file.fsPath), logService, (eventType, file) => this.onFileChangedInOutputDirector(eventType, file)));

this.resettingDelayer = new ThrottledDelayer<void>(50);
Expand Down Expand Up @@ -301,7 +304,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out

private onFileChangedInOutputDirector(eventType: string, fileName: string): void {
// Check if rotating file has changed. It changes only when the main file exceeds its limit.
if (`${paths.basename(this.file.fsPath)}.1` === fileName) {
if (this.rotatingFilePath === fileName) {
this.resettingDelayer.trigger(() => this.resetModel());
}
}
Expand Down Expand Up @@ -554,9 +557,8 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
if (channelData && channelData.file) {
return this.instantiationService.createInstance(FileOutputChannel, channelData, uri);
}
const file = URI.file(paths.join(this.outputDir, `${id}.log`));
try {
return this.instantiationService.createInstance(OutputChannelBackedByFile, { id, label: channelData ? channelData.label : '', file }, uri);
return this.instantiationService.createInstance(OutputChannelBackedByFile, { id, label: channelData ? channelData.label : '' }, this.outputDir, uri);
} catch (e) {
this.logService.error(e);
this.telemetryService.publicLog('output.used.bufferedChannel');
Expand Down

0 comments on commit 6266e0f

Please sign in to comment.