Skip to content

Commit 841f1d3

Browse files
author
Dave Bartolomeo
committed
Replace console logging to route through problem reporter
1 parent 99756ae commit 841f1d3

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

extensions/ql-vscode/src/log-insights/join-order.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ function getMainHash(event: InLayer | ComputeRecursive): string {
7676
/**
7777
* Sum arrays a and b element-wise. The shorter array is padded with 0s if the arrays are not the same length.
7878
*/
79-
function pointwiseSum(a: Int32Array, b: Int32Array): Int32Array {
79+
function pointwiseSum(a: Int32Array, b: Int32Array, problemReporter: EvaluationLogProblemReporter): Int32Array {
8080
function reportIfInconsistent(ai: number, bi: number) {
8181
if (ai === -1 && bi !== -1) {
82-
console.warn(
82+
problemReporter.log(
8383
`Operation was not evaluated in the first pipeline, but it was evaluated in the accumulated pipeline (with tuple count ${bi}).`
8484
);
8585
}
8686
if (ai !== -1 && bi === -1) {
87-
console.warn(
87+
problemReporter.log(
8888
`Operation was evaluated in the first pipeline (with tuple count ${ai}), but it was not evaluated in the accumulated pipeline.`
8989
);
9090
}
@@ -436,7 +436,8 @@ class JoinOrderScanner implements EvaluationLogScanner {
436436
// Pointwise sum the tuple counts
437437
const newTupleCounts = pointwiseSum(
438438
bucket.tupleCounts,
439-
new Int32Array(run.counts)
439+
new Int32Array(run.counts),
440+
this.problemReporter
440441
);
441442
const newResultSizes = bucket.resultSize + resultSizes!;
442443
// Pointwise sum the deltas.

extensions/ql-vscode/src/log-insights/log-scanner-service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { QueryHistoryInfo } from '../query-results';
55
import { EvaluationLogProblemReporter, EvaluationLogScannerSet } from './log-scanner';
66
import { PipelineInfo, SummarySymbols } from './summary-parser';
77
import * as fs from 'fs-extra';
8+
import { logger } from '../logging';
89

910
/**
1011
* Compute the key used to find a predicate in the summary symbols.
@@ -39,6 +40,10 @@ class ProblemReporter implements EvaluationLogProblemReporter {
3940
this.diagnostics.push(new Diagnostic(range, message, DiagnosticSeverity.Error));
4041
}
4142
}
43+
44+
public log(message: string): void {
45+
void logger.log(message);
46+
}
4247
}
4348

4449
export class LogScannerService extends DisposableObject {

extensions/ql-vscode/src/log-insights/log-scanner.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export interface EvaluationLogProblemReporter {
1515
* @param message The problem message.
1616
*/
1717
reportProblem(predicateName: string, raHash: string, iteration: number, message: string): void;
18+
19+
/**
20+
* Log a message about a problem in the implementation of the scanner. These will typically be
21+
* displayed separate from any problems reported via `reportProblem()`.
22+
*/
23+
log(message: string): void;
1824
}
1925

2026
/**

extensions/ql-vscode/test/pure-tests/log-scanner.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class TestProblemReporter implements EvaluationLogProblemReporter {
2222
message
2323
});
2424
}
25+
26+
public log(message: string): void {
27+
console.log(message);
28+
}
2529
}
2630

2731
describe('log scanners', function() {

0 commit comments

Comments
 (0)