Skip to content

Commit

Permalink
#40196 Check if rotating file has changed to know if main file was reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Dec 19, 2017
1 parent 91c4a3c commit 6f4f153
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/vs/workbench/parts/output/electron-browser/outputServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { OutputLinkProvider } from 'vs/workbench/parts/output/common/outputLinkP
import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { IModel } from 'vs/editor/common/editorCommon';
import { IModeService } from 'vs/editor/common/services/modeService';
import { RunOnceScheduler } from 'vs/base/common/async';
import { RunOnceScheduler, ThrottledDelayer } from 'vs/base/common/async';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Position } from 'vs/editor/common/core/position';
import { IFileService, FileChangeType } from 'vs/platform/files/common/files';
Expand Down Expand Up @@ -183,6 +183,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
private outputWriter: RotatingLogger;
private appendedMessage = '';
private loadingFromFileInProgress: boolean = false;
private resettingDelayer: ThrottledDelayer<void>;

constructor(
outputChannelIdentifier: IOutputChannelIdentifier,
Expand All @@ -194,9 +195,12 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
) {
super(outputChannelIdentifier, fileService, modelService, modeService, panelService);

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

this.resettingDelayer = new ThrottledDelayer<void>(50);
}

append(message: string): void {
Expand Down Expand Up @@ -253,8 +257,9 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
}

private onFileChangedInOutputDirector(eventType: string, fileName: string): void {
if (paths.basename(this.file.fsPath) === fileName) {
this.resetModel();
// Check if rotating file has changed. It changes only when the main file exceeds its limit.
if (`${paths.basename(this.file.fsPath)}.1` === fileName) {
this.resettingDelayer.trigger(() => this.resetModel());
}
}
}
Expand Down

0 comments on commit 6f4f153

Please sign in to comment.