@codingame/monaco-vscode-output-service-override 13.1.7 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -4
- package/package.json +10 -9
- package/vscode/src/vs/workbench/contrib/output/browser/output.contribution.js +354 -77
- package/vscode/src/vs/workbench/contrib/output/browser/outputServices.d.ts +68 -5
- package/vscode/src/vs/workbench/contrib/output/browser/outputServices.js +289 -22
- package/vscode/src/vs/workbench/contrib/output/browser/outputView.d.ts +58 -4
- package/vscode/src/vs/workbench/contrib/output/browser/outputView.js +244 -14
- package/vscode/src/vs/workbench/contrib/output/common/outputChannelModel.d.ts +55 -22
- package/vscode/src/vs/workbench/contrib/output/common/outputChannelModel.js +508 -119
- package/vscode/src/vs/workbench/contrib/output/common/outputChannelModelService.d.ts +0 -16
- package/vscode/src/vs/workbench/contrib/output/common/outputChannelModelService.js +0 -34
|
@@ -1,42 +1,148 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
|
-
import { joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
4
|
+
import { extUri, joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
5
5
|
import { IEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker';
|
|
6
|
-
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
7
7
|
import { ThrottledDelayer, Promises } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
8
|
+
import { toFileOperationResult, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
8
9
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
9
10
|
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model';
|
|
10
|
-
import { Disposable,
|
|
11
|
+
import { Disposable, toDisposable, DisposableStore, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
11
12
|
import { isNumber } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
12
13
|
import { EditOperation } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/editOperation';
|
|
13
14
|
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
14
15
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
15
16
|
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
17
|
+
import { LogLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
|
|
16
18
|
import { ILogService, ILoggerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
17
19
|
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
18
|
-
import { OutputChannelUpdateMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output';
|
|
20
|
+
import { LOG_MIME, OutputChannelUpdateMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output';
|
|
19
21
|
import { isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
22
|
+
import { TextModel } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
|
|
23
|
+
import { sortedDiff, binarySearch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
const LOG_ENTRY_REGEX = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\s(\[(info|trace|debug|error|warning)\])\s(\[(.*?)\])?/;
|
|
26
|
+
function parseLogEntryAt(model, lineNumber) {
|
|
27
|
+
const lineContent = model.getLineContent(lineNumber);
|
|
28
|
+
const match = LOG_ENTRY_REGEX.exec(lineContent);
|
|
29
|
+
if (match) {
|
|
30
|
+
const timestamp = ( new Date(match[1])).getTime();
|
|
31
|
+
const timestampRange = ( new Range(lineNumber, 1, lineNumber, match[1].length));
|
|
32
|
+
const logLevel = parseLogLevel(match[3]);
|
|
33
|
+
const logLevelRange = ( new Range(
|
|
34
|
+
lineNumber,
|
|
35
|
+
timestampRange.endColumn + 1,
|
|
36
|
+
lineNumber,
|
|
37
|
+
timestampRange.endColumn + 1 + match[2].length
|
|
38
|
+
));
|
|
39
|
+
const category = match[5];
|
|
40
|
+
const startLine = lineNumber;
|
|
41
|
+
let endLine = lineNumber;
|
|
42
|
+
const lineCount = model.getLineCount();
|
|
43
|
+
while (endLine < lineCount) {
|
|
44
|
+
const nextLineContent = model.getLineContent(endLine + 1);
|
|
45
|
+
const isLastLine = endLine + 1 === lineCount && nextLineContent === '';
|
|
46
|
+
if (LOG_ENTRY_REGEX.test(nextLineContent) || isLastLine) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
endLine++;
|
|
50
|
+
}
|
|
51
|
+
const range = ( new Range(startLine, 1, endLine, model.getLineMaxColumn(endLine)));
|
|
52
|
+
return { range, timestamp, timestampRange, logLevel, logLevelRange, category };
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function* logEntryIterator(model, process) {
|
|
57
|
+
for (let lineNumber = 1; lineNumber <= model.getLineCount(); lineNumber++) {
|
|
58
|
+
const logEntry = parseLogEntryAt(model, lineNumber);
|
|
59
|
+
if (logEntry) {
|
|
60
|
+
yield process(logEntry);
|
|
61
|
+
lineNumber = logEntry.range.endLineNumber;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function changeStartLineNumber(logEntry, lineNumber) {
|
|
66
|
+
return {
|
|
67
|
+
...logEntry,
|
|
68
|
+
range: ( new Range(
|
|
69
|
+
lineNumber,
|
|
70
|
+
logEntry.range.startColumn,
|
|
71
|
+
lineNumber + logEntry.range.endLineNumber - logEntry.range.startLineNumber,
|
|
72
|
+
logEntry.range.endColumn
|
|
73
|
+
)),
|
|
74
|
+
timestampRange: ( new Range(
|
|
75
|
+
lineNumber,
|
|
76
|
+
logEntry.timestampRange.startColumn,
|
|
77
|
+
lineNumber,
|
|
78
|
+
logEntry.timestampRange.endColumn
|
|
79
|
+
)),
|
|
80
|
+
logLevelRange: ( new Range(
|
|
81
|
+
lineNumber,
|
|
82
|
+
logEntry.logLevelRange.startColumn,
|
|
83
|
+
lineNumber,
|
|
84
|
+
logEntry.logLevelRange.endColumn
|
|
85
|
+
)),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function parseLogLevel(level) {
|
|
89
|
+
switch (level.toLowerCase()) {
|
|
90
|
+
case 'trace':
|
|
91
|
+
return LogLevel.Trace;
|
|
92
|
+
case 'debug':
|
|
93
|
+
return LogLevel.Debug;
|
|
94
|
+
case 'info':
|
|
95
|
+
return LogLevel.Info;
|
|
96
|
+
case 'warning':
|
|
97
|
+
return LogLevel.Warning;
|
|
98
|
+
case 'error':
|
|
99
|
+
return LogLevel.Error;
|
|
100
|
+
default:
|
|
101
|
+
throw ( new Error(`Unknown log level: ${level}`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
let FileContentProvider = class FileContentProvider extends Disposable {
|
|
105
|
+
constructor({ name, resource }, fileService, instantiationService, logService) {
|
|
23
106
|
super();
|
|
24
|
-
this.file = file;
|
|
25
107
|
this.fileService = fileService;
|
|
108
|
+
this.instantiationService = instantiationService;
|
|
26
109
|
this.logService = logService;
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
110
|
+
this._onDidAppend = ( new Emitter());
|
|
111
|
+
this.onDidAppend = this._onDidAppend.event;
|
|
112
|
+
this._onDidReset = ( new Emitter());
|
|
113
|
+
this.onDidReset = this._onDidReset.event;
|
|
29
114
|
this.watching = false;
|
|
115
|
+
this.etag = '';
|
|
116
|
+
this.logEntries = [];
|
|
117
|
+
this.startOffset = 0;
|
|
118
|
+
this.endOffset = 0;
|
|
119
|
+
this.name = name ?? '';
|
|
120
|
+
this.resource = resource;
|
|
30
121
|
this.syncDelayer = ( new ThrottledDelayer(500));
|
|
122
|
+
this._register(toDisposable(() => this.unwatch()));
|
|
123
|
+
}
|
|
124
|
+
reset(offset) {
|
|
125
|
+
this.endOffset = this.startOffset = offset ?? this.startOffset;
|
|
126
|
+
this.logEntries = [];
|
|
31
127
|
}
|
|
32
|
-
|
|
128
|
+
resetToEnd() {
|
|
129
|
+
this.startOffset = this.endOffset;
|
|
130
|
+
this.logEntries = [];
|
|
131
|
+
}
|
|
132
|
+
watch() {
|
|
33
133
|
if (!this.watching) {
|
|
34
|
-
this.
|
|
134
|
+
this.logService.trace('Started polling', ( this.resource.toString()));
|
|
35
135
|
this.poll();
|
|
36
|
-
this.logService.trace('Started polling', ( this.file.toString()));
|
|
37
136
|
this.watching = true;
|
|
38
137
|
}
|
|
39
138
|
}
|
|
139
|
+
unwatch() {
|
|
140
|
+
if (this.watching) {
|
|
141
|
+
this.syncDelayer.cancel();
|
|
142
|
+
this.watching = false;
|
|
143
|
+
this.logService.trace('Stopped polling', ( this.resource.toString()));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
40
146
|
poll() {
|
|
41
147
|
const loop = () => this.doWatch().then(() => this.poll());
|
|
42
148
|
this.syncDelayer.trigger(loop).catch(error => {
|
|
@@ -46,75 +152,305 @@ class OutputFileListener extends Disposable {
|
|
|
46
152
|
});
|
|
47
153
|
}
|
|
48
154
|
async doWatch() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
155
|
+
try {
|
|
156
|
+
if (!this.fileService.hasProvider(this.resource)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const stat = await this.fileService.stat(this.resource);
|
|
160
|
+
if (stat.etag !== this.etag) {
|
|
161
|
+
this.etag = stat.etag;
|
|
162
|
+
if (isNumber(stat.size) && this.endOffset > stat.size) {
|
|
163
|
+
this.reset(0);
|
|
164
|
+
this._onDidReset.fire();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this._onDidAppend.fire();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (toFileOperationResult(error) !== FileOperationResult.FILE_NOT_FOUND) {
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getLogEntries() {
|
|
178
|
+
return this.logEntries;
|
|
179
|
+
}
|
|
180
|
+
async getContent(donotConsumeLogEntries) {
|
|
181
|
+
try {
|
|
182
|
+
if (!this.fileService.hasProvider(this.resource)) {
|
|
183
|
+
return {
|
|
184
|
+
name: this.name,
|
|
185
|
+
content: '',
|
|
186
|
+
consume: () => { }
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const fileContent = await this.fileService.readFile(this.resource, { position: this.endOffset });
|
|
190
|
+
const content = ( fileContent.value.toString());
|
|
191
|
+
const logEntries = donotConsumeLogEntries ? [] : this.parseLogEntries(content, this.logEntries[this.logEntries.length - 1]);
|
|
192
|
+
let consumed = false;
|
|
193
|
+
return {
|
|
194
|
+
name: this.name,
|
|
195
|
+
content,
|
|
196
|
+
consume: () => {
|
|
197
|
+
if (!consumed) {
|
|
198
|
+
consumed = true;
|
|
199
|
+
this.endOffset += fileContent.value.byteLength;
|
|
200
|
+
this.etag = fileContent.etag;
|
|
201
|
+
this.logEntries.push(...logEntries);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
if (toFileOperationResult(error) !== FileOperationResult.FILE_NOT_FOUND) {
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
name: this.name,
|
|
212
|
+
content: '',
|
|
213
|
+
consume: () => { }
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
parseLogEntries(content, lastLogEntry) {
|
|
218
|
+
const model = this.instantiationService.createInstance(TextModel, content, LOG_MIME, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
|
219
|
+
if (!parseLogEntryAt(model, 1)) {
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const logEntries = [];
|
|
224
|
+
let logEntryStartLineNumber = lastLogEntry ? lastLogEntry.range.endLineNumber + 1 : 1;
|
|
225
|
+
for (const entry of logEntryIterator(model, (e) => changeStartLineNumber(e, logEntryStartLineNumber))) {
|
|
226
|
+
logEntries.push(entry);
|
|
227
|
+
logEntryStartLineNumber = entry.range.endLineNumber + 1;
|
|
228
|
+
}
|
|
229
|
+
return logEntries;
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
model.dispose();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
FileContentProvider = ( __decorate([
|
|
237
|
+
( __param(1, IFileService)),
|
|
238
|
+
( __param(2, IInstantiationService)),
|
|
239
|
+
( __param(3, ILogService))
|
|
240
|
+
], FileContentProvider));
|
|
241
|
+
let MultiFileContentProvider = class MultiFileContentProvider extends Disposable {
|
|
242
|
+
constructor(filesInfos, instantiationService, fileService, logService) {
|
|
243
|
+
super();
|
|
244
|
+
this.instantiationService = instantiationService;
|
|
245
|
+
this.fileService = fileService;
|
|
246
|
+
this.logService = logService;
|
|
247
|
+
this._onDidAppend = this._register(( new Emitter()));
|
|
248
|
+
this.onDidAppend = this._onDidAppend.event;
|
|
249
|
+
this.onDidReset = Event.None;
|
|
250
|
+
this.logEntries = [];
|
|
251
|
+
this.fileContentProviderItems = [];
|
|
252
|
+
this.watching = false;
|
|
253
|
+
for (const file of filesInfos) {
|
|
254
|
+
this.fileContentProviderItems.push(this.createFileContentProvider(file));
|
|
255
|
+
}
|
|
256
|
+
this._register(toDisposable(() => {
|
|
257
|
+
for (const [, disposables] of this.fileContentProviderItems) {
|
|
258
|
+
disposables.dispose();
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
createFileContentProvider(file) {
|
|
263
|
+
const disposables = ( new DisposableStore());
|
|
264
|
+
const fileOutput = disposables.add(( new FileContentProvider(file, this.fileService, this.instantiationService, this.logService)));
|
|
265
|
+
disposables.add(fileOutput.onDidAppend(() => this._onDidAppend.fire()));
|
|
266
|
+
return [fileOutput, disposables];
|
|
267
|
+
}
|
|
268
|
+
watch() {
|
|
269
|
+
if (!this.watching) {
|
|
270
|
+
this.watching = true;
|
|
271
|
+
for (const [output] of this.fileContentProviderItems) {
|
|
272
|
+
output.watch();
|
|
273
|
+
}
|
|
53
274
|
}
|
|
54
275
|
}
|
|
55
276
|
unwatch() {
|
|
56
277
|
if (this.watching) {
|
|
57
|
-
this.syncDelayer.cancel();
|
|
58
278
|
this.watching = false;
|
|
59
|
-
|
|
279
|
+
for (const [output] of this.fileContentProviderItems) {
|
|
280
|
+
output.unwatch();
|
|
281
|
+
}
|
|
60
282
|
}
|
|
61
283
|
}
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
284
|
+
updateFiles(files) {
|
|
285
|
+
const wasWatching = this.watching;
|
|
286
|
+
if (wasWatching) {
|
|
287
|
+
this.unwatch();
|
|
288
|
+
}
|
|
289
|
+
const result = sortedDiff(( this.fileContentProviderItems.map(([output]) => output)), files, (a, b) => extUri.compare(a.resource, b.resource));
|
|
290
|
+
for (const { start, deleteCount, toInsert } of result) {
|
|
291
|
+
const outputs = ( toInsert.map(file => this.createFileContentProvider(file)));
|
|
292
|
+
const outputsToRemove = this.fileContentProviderItems.splice(start, deleteCount, ...outputs);
|
|
293
|
+
for (const [, disposables] of outputsToRemove) {
|
|
294
|
+
disposables.dispose();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (wasWatching) {
|
|
298
|
+
this.watch();
|
|
299
|
+
}
|
|
65
300
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
301
|
+
reset() {
|
|
302
|
+
for (const [output] of this.fileContentProviderItems) {
|
|
303
|
+
output.reset();
|
|
304
|
+
}
|
|
305
|
+
this.logEntries = [];
|
|
306
|
+
}
|
|
307
|
+
resetToEnd() {
|
|
308
|
+
for (const [output] of this.fileContentProviderItems) {
|
|
309
|
+
output.resetToEnd();
|
|
310
|
+
}
|
|
311
|
+
this.logEntries = [];
|
|
312
|
+
}
|
|
313
|
+
getLogEntries() {
|
|
314
|
+
return this.logEntries;
|
|
315
|
+
}
|
|
316
|
+
async getContent() {
|
|
317
|
+
const outputs = await Promise.all(( this.fileContentProviderItems.map(([output]) => output.getContent(true))));
|
|
318
|
+
const { content, logEntries } = this.combineLogEntries(outputs, this.logEntries[this.logEntries.length - 1]);
|
|
319
|
+
let consumed = false;
|
|
320
|
+
return {
|
|
321
|
+
content,
|
|
322
|
+
consume: () => {
|
|
323
|
+
if (!consumed) {
|
|
324
|
+
consumed = true;
|
|
325
|
+
outputs.forEach(({ consume }) => consume());
|
|
326
|
+
this.logEntries.push(...logEntries);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
combineLogEntries(outputs, lastEntry) {
|
|
332
|
+
outputs = outputs.filter(output => !!output.content);
|
|
333
|
+
if (outputs.length === 0) {
|
|
334
|
+
return { logEntries: [], content: '' };
|
|
335
|
+
}
|
|
336
|
+
const logEntries = [];
|
|
337
|
+
const contents = [];
|
|
338
|
+
const process = (model, logEntry, name) => {
|
|
339
|
+
const lineContent = model.getValueInRange(logEntry.range);
|
|
340
|
+
const content = name ? `${lineContent.substring(0, logEntry.logLevelRange.endColumn)} [${name}]${lineContent.substring(logEntry.logLevelRange.endColumn)}` : lineContent;
|
|
341
|
+
return [{
|
|
342
|
+
...logEntry,
|
|
343
|
+
category: name,
|
|
344
|
+
range: ( new Range(
|
|
345
|
+
logEntry.range.startLineNumber,
|
|
346
|
+
logEntry.logLevelRange.startColumn,
|
|
347
|
+
logEntry.range.endLineNumber,
|
|
348
|
+
name ? logEntry.range.endColumn + name.length + 3 : logEntry.range.endColumn
|
|
349
|
+
)),
|
|
350
|
+
}, content];
|
|
351
|
+
};
|
|
352
|
+
const model = this.instantiationService.createInstance(TextModel, outputs[0].content, LOG_MIME, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
|
353
|
+
try {
|
|
354
|
+
for (const [logEntry, content] of logEntryIterator(model, (e) => process(model, e, outputs[0].name))) {
|
|
355
|
+
logEntries.push(logEntry);
|
|
356
|
+
contents.push(content);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
model.dispose();
|
|
361
|
+
}
|
|
362
|
+
for (let index = 1; index < outputs.length; index++) {
|
|
363
|
+
const { content, name } = outputs[index];
|
|
364
|
+
const model = this.instantiationService.createInstance(TextModel, content, LOG_MIME, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
|
365
|
+
try {
|
|
366
|
+
const iterator = logEntryIterator(model, (e) => process(model, e, name));
|
|
367
|
+
let next = iterator.next();
|
|
368
|
+
while (!next.done) {
|
|
369
|
+
const [logEntry, content] = next.value;
|
|
370
|
+
const logEntriesToAdd = [logEntry];
|
|
371
|
+
const contentsToAdd = [content];
|
|
372
|
+
let insertionIndex;
|
|
373
|
+
if (logEntry.timestamp >= logEntries[logEntries.length - 1].timestamp) {
|
|
374
|
+
insertionIndex = logEntries.length;
|
|
375
|
+
for (next = iterator.next(); !next.done; next = iterator.next()) {
|
|
376
|
+
logEntriesToAdd.push(next.value[0]);
|
|
377
|
+
contentsToAdd.push(next.value[1]);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
if (logEntry.timestamp <= logEntries[0].timestamp) {
|
|
382
|
+
insertionIndex = 0;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
const idx = binarySearch(logEntries, logEntry, (a, b) => a.timestamp - b.timestamp);
|
|
386
|
+
insertionIndex = idx < 0 ? ~idx : idx;
|
|
387
|
+
}
|
|
388
|
+
for (next = iterator.next(); !next.done && next.value[0].timestamp <= logEntries[insertionIndex].timestamp; next = iterator.next()) {
|
|
389
|
+
logEntriesToAdd.push(next.value[0]);
|
|
390
|
+
contentsToAdd.push(next.value[1]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
contents.splice(insertionIndex, 0, ...contentsToAdd);
|
|
394
|
+
logEntries.splice(insertionIndex, 0, ...logEntriesToAdd);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
finally {
|
|
398
|
+
model.dispose();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let content = '';
|
|
402
|
+
const updatedLogEntries = [];
|
|
403
|
+
let logEntryStartLineNumber = lastEntry ? lastEntry.range.endLineNumber + 1 : 1;
|
|
404
|
+
for (let i = 0; i < logEntries.length; i++) {
|
|
405
|
+
content += contents[i] + '\n';
|
|
406
|
+
const updatedLogEntry = changeStartLineNumber(logEntries[i], logEntryStartLineNumber);
|
|
407
|
+
updatedLogEntries.push(updatedLogEntry);
|
|
408
|
+
logEntryStartLineNumber = updatedLogEntry.range.endLineNumber + 1;
|
|
409
|
+
}
|
|
410
|
+
return { logEntries: updatedLogEntries, content };
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
MultiFileContentProvider = ( __decorate([
|
|
414
|
+
( __param(1, IInstantiationService)),
|
|
415
|
+
( __param(2, IFileService)),
|
|
416
|
+
( __param(3, ILogService))
|
|
417
|
+
], MultiFileContentProvider));
|
|
418
|
+
let AbstractFileOutputChannelModel = class AbstractFileOutputChannelModel extends Disposable {
|
|
419
|
+
constructor(modelUri, language, outputContentProvider, modelService, editorWorkerService) {
|
|
69
420
|
super();
|
|
70
421
|
this.modelUri = modelUri;
|
|
71
422
|
this.language = language;
|
|
72
|
-
this.
|
|
73
|
-
this.fileService = fileService;
|
|
423
|
+
this.outputContentProvider = outputContentProvider;
|
|
74
424
|
this.modelService = modelService;
|
|
75
425
|
this.editorWorkerService = editorWorkerService;
|
|
76
426
|
this._onDispose = this._register(( new Emitter()));
|
|
77
427
|
this.onDispose = this._onDispose.event;
|
|
78
|
-
this.etag = '';
|
|
79
428
|
this.loadModelPromise = null;
|
|
429
|
+
this.modelDisposable = this._register(( new MutableDisposable()));
|
|
80
430
|
this.model = null;
|
|
81
431
|
this.modelUpdateInProgress = false;
|
|
82
432
|
this.modelUpdateCancellationSource = this._register(( new MutableDisposable()));
|
|
83
433
|
this.appendThrottler = this._register(( new ThrottledDelayer(300)));
|
|
84
|
-
this.startOffset = 0;
|
|
85
|
-
this.endOffset = 0;
|
|
86
|
-
this.fileHandler = this._register(( new OutputFileListener(this.file, this.fileService, logService)));
|
|
87
|
-
this._register(this.fileHandler.onDidContentChange(size => this.onDidContentChange(size)));
|
|
88
|
-
this._register(toDisposable(() => this.fileHandler.unwatch()));
|
|
89
|
-
}
|
|
90
|
-
append(message) {
|
|
91
|
-
throw ( new Error('Not supported'));
|
|
92
|
-
}
|
|
93
|
-
replace(message) {
|
|
94
|
-
throw ( new Error('Not supported'));
|
|
95
434
|
}
|
|
96
|
-
|
|
97
|
-
this.update(OutputChannelUpdateMode.Clear, this.endOffset, true);
|
|
98
|
-
}
|
|
99
|
-
update(mode, till, immediate) {
|
|
100
|
-
const loadModelPromise = this.loadModelPromise ? this.loadModelPromise : Promise.resolve();
|
|
101
|
-
loadModelPromise.then(() => this.doUpdate(mode, till, immediate));
|
|
102
|
-
}
|
|
103
|
-
loadModel() {
|
|
435
|
+
async loadModel() {
|
|
104
436
|
this.loadModelPromise = Promises.withAsyncBody(async (c, e) => {
|
|
105
437
|
try {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
438
|
+
this.modelDisposable.value = ( new DisposableStore());
|
|
439
|
+
this.model = this.modelService.createModel('', this.language, this.modelUri);
|
|
440
|
+
const { content, consume } = await this.outputContentProvider.getContent();
|
|
441
|
+
consume();
|
|
442
|
+
this.doAppendContent(this.model, content);
|
|
443
|
+
this.modelDisposable.value.add(this.outputContentProvider.onDidReset(() => this.onDidContentChange(true, true)));
|
|
444
|
+
this.modelDisposable.value.add(this.outputContentProvider.onDidAppend(() => this.onDidContentChange(false, false)));
|
|
445
|
+
this.outputContentProvider.watch();
|
|
446
|
+
this.modelDisposable.value.add(toDisposable(() => this.outputContentProvider.unwatch()));
|
|
447
|
+
this.modelDisposable.value.add(this.model.onWillDispose(() => {
|
|
448
|
+
this.outputContentProvider.reset();
|
|
449
|
+
this.modelDisposable.value = undefined;
|
|
450
|
+
this.cancelModelUpdate();
|
|
451
|
+
this.model = null;
|
|
452
|
+
}));
|
|
453
|
+
c(this.model);
|
|
118
454
|
}
|
|
119
455
|
catch (error) {
|
|
120
456
|
e(error);
|
|
@@ -122,25 +458,17 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
122
458
|
});
|
|
123
459
|
return this.loadModelPromise;
|
|
124
460
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
461
|
+
getLogEntries() {
|
|
462
|
+
return this.outputContentProvider.getLogEntries();
|
|
463
|
+
}
|
|
464
|
+
onDidContentChange(reset, appendImmediately) {
|
|
465
|
+
if (reset && !this.modelUpdateInProgress) {
|
|
466
|
+
this.doUpdate(OutputChannelUpdateMode.Clear, true);
|
|
128
467
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const disposable = this.model.onWillDispose(() => {
|
|
133
|
-
this.cancelModelUpdate();
|
|
134
|
-
this.fileHandler.unwatch();
|
|
135
|
-
this.model = null;
|
|
136
|
-
dispose(disposable);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return this.model;
|
|
140
|
-
}
|
|
141
|
-
doUpdate(mode, till, immediate) {
|
|
468
|
+
this.doUpdate(OutputChannelUpdateMode.Append, appendImmediately);
|
|
469
|
+
}
|
|
470
|
+
doUpdate(mode, immediate) {
|
|
142
471
|
if (mode === OutputChannelUpdateMode.Clear || mode === OutputChannelUpdateMode.Replace) {
|
|
143
|
-
this.startOffset = this.endOffset = isNumber(till) ? till : this.endOffset;
|
|
144
472
|
this.cancelModelUpdate();
|
|
145
473
|
}
|
|
146
474
|
if (!this.model) {
|
|
@@ -162,7 +490,8 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
162
490
|
}
|
|
163
491
|
}
|
|
164
492
|
clearContent(model) {
|
|
165
|
-
|
|
493
|
+
model.applyEdits([EditOperation.delete(model.getFullModelRange())]);
|
|
494
|
+
this.modelUpdateInProgress = false;
|
|
166
495
|
}
|
|
167
496
|
appendContent(model, immediate, token) {
|
|
168
497
|
this.appendThrottler.trigger(async () => {
|
|
@@ -178,30 +507,38 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
178
507
|
return;
|
|
179
508
|
}
|
|
180
509
|
}
|
|
181
|
-
const
|
|
510
|
+
const { content, consume } = await this.outputContentProvider.getContent();
|
|
182
511
|
if (token.isCancellationRequested) {
|
|
183
512
|
return;
|
|
184
513
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this.doUpdateModel(model, edits, contentToAppend);
|
|
514
|
+
consume();
|
|
515
|
+
this.doAppendContent(model, content);
|
|
516
|
+
this.modelUpdateInProgress = false;
|
|
189
517
|
}, immediate ? 0 : undefined).catch(error => {
|
|
190
518
|
if (!isCancellationError(error)) {
|
|
191
519
|
throw error;
|
|
192
520
|
}
|
|
193
521
|
});
|
|
194
522
|
}
|
|
523
|
+
doAppendContent(model, content) {
|
|
524
|
+
const lastLine = model.getLineCount();
|
|
525
|
+
const lastLineMaxColumn = model.getLineMaxColumn(lastLine);
|
|
526
|
+
model.applyEdits([EditOperation.insert(( new Position(lastLine, lastLineMaxColumn)), content)]);
|
|
527
|
+
}
|
|
195
528
|
async replaceContent(model, token) {
|
|
196
|
-
const
|
|
529
|
+
const { content, consume } = await this.outputContentProvider.getContent();
|
|
197
530
|
if (token.isCancellationRequested) {
|
|
198
531
|
return;
|
|
199
532
|
}
|
|
200
|
-
const edits = await this.getReplaceEdits(model, (
|
|
533
|
+
const edits = await this.getReplaceEdits(model, ( content.toString()));
|
|
201
534
|
if (token.isCancellationRequested) {
|
|
202
535
|
return;
|
|
203
536
|
}
|
|
204
|
-
|
|
537
|
+
consume();
|
|
538
|
+
if (edits.length) {
|
|
539
|
+
model.applyEdits(edits);
|
|
540
|
+
}
|
|
541
|
+
this.modelUpdateInProgress = false;
|
|
205
542
|
}
|
|
206
543
|
async getReplaceEdits(model, contentToReplace) {
|
|
207
544
|
if (!contentToReplace) {
|
|
@@ -215,13 +552,6 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
215
552
|
}
|
|
216
553
|
return [];
|
|
217
554
|
}
|
|
218
|
-
doUpdateModel(model, edits, content) {
|
|
219
|
-
if (edits.length) {
|
|
220
|
-
model.applyEdits(edits);
|
|
221
|
-
}
|
|
222
|
-
this.endOffset = this.endOffset + content.byteLength;
|
|
223
|
-
this.modelUpdateInProgress = false;
|
|
224
|
-
}
|
|
225
555
|
cancelModelUpdate() {
|
|
226
556
|
this.modelUpdateCancellationSource.value?.cancel();
|
|
227
557
|
this.modelUpdateCancellationSource.value = undefined;
|
|
@@ -229,21 +559,6 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
229
559
|
this.replacePromise = undefined;
|
|
230
560
|
this.modelUpdateInProgress = false;
|
|
231
561
|
}
|
|
232
|
-
async getContentToUpdate() {
|
|
233
|
-
const content = await this.fileService.readFile(this.file, { position: this.endOffset });
|
|
234
|
-
this.etag = content.etag;
|
|
235
|
-
return content.value;
|
|
236
|
-
}
|
|
237
|
-
onDidContentChange(size) {
|
|
238
|
-
if (this.model) {
|
|
239
|
-
if (!this.modelUpdateInProgress) {
|
|
240
|
-
if (isNumber(size) && this.endOffset > size) {
|
|
241
|
-
this.update(OutputChannelUpdateMode.Clear, 0, true);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
this.update(OutputChannelUpdateMode.Append, undefined, false );
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
562
|
isVisible() {
|
|
248
563
|
return !!this.model;
|
|
249
564
|
}
|
|
@@ -251,16 +566,81 @@ let FileOutputChannelModel = class FileOutputChannelModel extends Disposable {
|
|
|
251
566
|
this._onDispose.fire();
|
|
252
567
|
super.dispose();
|
|
253
568
|
}
|
|
569
|
+
append(message) { throw ( new Error('Not supported')); }
|
|
570
|
+
replace(message) { throw ( new Error('Not supported')); }
|
|
571
|
+
};
|
|
572
|
+
AbstractFileOutputChannelModel = ( __decorate([
|
|
573
|
+
( __param(3, IModelService)),
|
|
574
|
+
( __param(4, IEditorWorkerService))
|
|
575
|
+
], AbstractFileOutputChannelModel));
|
|
576
|
+
let FileOutputChannelModel = class FileOutputChannelModel extends AbstractFileOutputChannelModel {
|
|
577
|
+
constructor(modelUri, language, source, fileService, modelService, instantiationService, logService, editorWorkerService) {
|
|
578
|
+
const fileOutput = ( new FileContentProvider(source, fileService, instantiationService, logService));
|
|
579
|
+
super(modelUri, language, fileOutput, modelService, editorWorkerService);
|
|
580
|
+
this.source = source;
|
|
581
|
+
this.fileOutput = this._register(fileOutput);
|
|
582
|
+
}
|
|
583
|
+
clear() {
|
|
584
|
+
this.update(OutputChannelUpdateMode.Clear, undefined, true);
|
|
585
|
+
}
|
|
586
|
+
update(mode, till, immediate) {
|
|
587
|
+
const loadModelPromise = this.loadModelPromise ? this.loadModelPromise : Promise.resolve();
|
|
588
|
+
loadModelPromise.then(() => {
|
|
589
|
+
if (mode === OutputChannelUpdateMode.Clear || mode === OutputChannelUpdateMode.Replace) {
|
|
590
|
+
if (isNumber(till)) {
|
|
591
|
+
this.fileOutput.reset(till);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
this.fileOutput.resetToEnd();
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
this.doUpdate(mode, immediate);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
updateChannelSources(files) { throw ( new Error('Not supported')); }
|
|
254
601
|
};
|
|
255
602
|
FileOutputChannelModel = ( __decorate([
|
|
256
603
|
( __param(3, IFileService)),
|
|
257
604
|
( __param(4, IModelService)),
|
|
258
|
-
( __param(5,
|
|
259
|
-
( __param(6,
|
|
605
|
+
( __param(5, IInstantiationService)),
|
|
606
|
+
( __param(6, ILogService)),
|
|
607
|
+
( __param(7, IEditorWorkerService))
|
|
260
608
|
], FileOutputChannelModel));
|
|
609
|
+
let MultiFileOutputChannelModel = class MultiFileOutputChannelModel extends AbstractFileOutputChannelModel {
|
|
610
|
+
constructor(modelUri, language, source, fileService, modelService, logService, editorWorkerService, instantiationService) {
|
|
611
|
+
const multifileOutput = ( new MultiFileContentProvider(source, instantiationService, fileService, logService));
|
|
612
|
+
super(modelUri, language, multifileOutput, modelService, editorWorkerService);
|
|
613
|
+
this.source = source;
|
|
614
|
+
this.multifileOutput = this._register(multifileOutput);
|
|
615
|
+
}
|
|
616
|
+
updateChannelSources(files) {
|
|
617
|
+
this.multifileOutput.unwatch();
|
|
618
|
+
this.multifileOutput.updateFiles(files);
|
|
619
|
+
this.multifileOutput.reset();
|
|
620
|
+
this.doUpdate(OutputChannelUpdateMode.Replace, true);
|
|
621
|
+
if (this.isVisible()) {
|
|
622
|
+
this.multifileOutput.watch();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
clear() {
|
|
626
|
+
const loadModelPromise = this.loadModelPromise ? this.loadModelPromise : Promise.resolve();
|
|
627
|
+
loadModelPromise.then(() => {
|
|
628
|
+
this.multifileOutput.resetToEnd();
|
|
629
|
+
this.doUpdate(OutputChannelUpdateMode.Clear, true);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
update(mode, till, immediate) { throw ( new Error('Not supported')); }
|
|
633
|
+
};
|
|
634
|
+
MultiFileOutputChannelModel = ( __decorate([
|
|
635
|
+
( __param(3, IFileService)),
|
|
636
|
+
( __param(4, IModelService)),
|
|
637
|
+
( __param(5, ILogService)),
|
|
638
|
+
( __param(6, IEditorWorkerService)),
|
|
639
|
+
( __param(7, IInstantiationService))
|
|
640
|
+
], MultiFileOutputChannelModel));
|
|
261
641
|
let OutputChannelBackedByFile = class OutputChannelBackedByFile extends FileOutputChannelModel {
|
|
262
|
-
constructor(id, modelUri, language, file, fileService, modelService, loggerService, logService, editorWorkerService) {
|
|
263
|
-
super(modelUri, language, file, fileService, modelService, logService, editorWorkerService);
|
|
642
|
+
constructor(id, modelUri, language, file, fileService, modelService, loggerService, instantiationService, logService, editorWorkerService) {
|
|
643
|
+
super(modelUri, language, { resource: file, name: '' }, fileService, modelService, instantiationService, logService, editorWorkerService);
|
|
264
644
|
this.logger = loggerService.createLogger(file, { logLevel: 'always', donotRotate: true, donotUseFormatters: true, hidden: true });
|
|
265
645
|
this._offset = 0;
|
|
266
646
|
}
|
|
@@ -285,26 +665,32 @@ OutputChannelBackedByFile = ( __decorate([
|
|
|
285
665
|
( __param(4, IFileService)),
|
|
286
666
|
( __param(5, IModelService)),
|
|
287
667
|
( __param(6, ILoggerService)),
|
|
288
|
-
( __param(7,
|
|
289
|
-
( __param(8,
|
|
668
|
+
( __param(7, IInstantiationService)),
|
|
669
|
+
( __param(8, ILogService)),
|
|
670
|
+
( __param(9, IEditorWorkerService))
|
|
290
671
|
], OutputChannelBackedByFile));
|
|
291
672
|
let DelegatedOutputChannelModel = class DelegatedOutputChannelModel extends Disposable {
|
|
292
|
-
constructor(id, modelUri, language, outputDir, instantiationService, fileService) {
|
|
673
|
+
constructor(id, modelUri, language, outputDir, outputDirCreationPromise, instantiationService, fileService) {
|
|
293
674
|
super();
|
|
294
675
|
this.instantiationService = instantiationService;
|
|
295
676
|
this.fileService = fileService;
|
|
296
677
|
this._onDispose = this._register(( new Emitter()));
|
|
297
678
|
this.onDispose = this._onDispose.event;
|
|
298
|
-
this.outputChannelModel = this.createOutputChannelModel(id, modelUri, language, outputDir);
|
|
679
|
+
this.outputChannelModel = this.createOutputChannelModel(id, modelUri, language, outputDir, outputDirCreationPromise);
|
|
680
|
+
const resource = joinPath(outputDir, `${id.replace(/[\\/:\*\?"<>\|]/g, '')}.log`);
|
|
681
|
+
this.source = { resource };
|
|
299
682
|
}
|
|
300
|
-
async createOutputChannelModel(id, modelUri, language, outputDirPromise) {
|
|
301
|
-
|
|
683
|
+
async createOutputChannelModel(id, modelUri, language, outputDir, outputDirPromise) {
|
|
684
|
+
await outputDirPromise;
|
|
302
685
|
const file = joinPath(outputDir, `${id.replace(/[\\/:\*\?"<>\|]/g, '')}.log`);
|
|
303
686
|
await this.fileService.createFile(file);
|
|
304
687
|
const outputChannelModel = this._register(this.instantiationService.createInstance(OutputChannelBackedByFile, id, modelUri, language, file));
|
|
305
688
|
this._register(outputChannelModel.onDispose(() => this._onDispose.fire()));
|
|
306
689
|
return outputChannelModel;
|
|
307
690
|
}
|
|
691
|
+
getLogEntries() {
|
|
692
|
+
return [];
|
|
693
|
+
}
|
|
308
694
|
append(output) {
|
|
309
695
|
this.outputChannelModel.then(outputChannelModel => outputChannelModel.append(output));
|
|
310
696
|
}
|
|
@@ -320,10 +706,13 @@ let DelegatedOutputChannelModel = class DelegatedOutputChannelModel extends Disp
|
|
|
320
706
|
replace(value) {
|
|
321
707
|
this.outputChannelModel.then(outputChannelModel => outputChannelModel.replace(value));
|
|
322
708
|
}
|
|
709
|
+
updateChannelSources(files) {
|
|
710
|
+
this.outputChannelModel.then(outputChannelModel => outputChannelModel.updateChannelSources(files));
|
|
711
|
+
}
|
|
323
712
|
};
|
|
324
713
|
DelegatedOutputChannelModel = ( __decorate([
|
|
325
|
-
( __param(
|
|
326
|
-
( __param(
|
|
714
|
+
( __param(5, IInstantiationService)),
|
|
715
|
+
( __param(6, IFileService))
|
|
327
716
|
], DelegatedOutputChannelModel));
|
|
328
717
|
|
|
329
|
-
export { DelegatedOutputChannelModel, FileOutputChannelModel };
|
|
718
|
+
export { AbstractFileOutputChannelModel, DelegatedOutputChannelModel, FileOutputChannelModel, MultiFileOutputChannelModel, parseLogEntryAt };
|