Skip to content

Commit c88ea0f

Browse files
authored
CHANGE @W-17701097@ Logfile now communicated at start. (#1745)
1 parent cee158c commit c88ea0f

File tree

13 files changed

+45
-8
lines changed

13 files changed

+45
-8
lines changed

messages/action-summary-viewer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# common.streaming-logs-to
2+
3+
Streaming logs in real time to:
4+
15
# common.summary-header
26

37
Summary

src/lib/actions/ConfigAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ConfigAction {
4141

4242
// We always add a Logger Listener to the appropriate listeners list, because we should always be logging.
4343
const logFileWriter: LogFileWriter = await LogFileWriter.fromConfig(userConfig);
44+
this.dependencies.actionSummaryViewer.viewPreExecutionSummary(logFileWriter.getLogDestination());
4445
const logEventLogger: LogEventLogger = new LogEventLogger(logFileWriter);
4546
this.dependencies.logEventListeners.push(logEventLogger);
4647

@@ -117,7 +118,7 @@ export class ConfigAction {
117118
this.dependencies.viewer.view(configModel);
118119
}
119120

120-
this.dependencies.actionSummaryViewer.view(logFileWriter.getLogDestination(), fileWritten ? input['output-file'] : undefined);
121+
this.dependencies.actionSummaryViewer.viewPostExecutionSummary(logFileWriter.getLogDestination(), fileWritten ? input['output-file'] : undefined);
121122
return Promise.resolve();
122123
}
123124

src/lib/actions/RulesAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class RulesAction {
3333
public async execute(input: RulesInput): Promise<void> {
3434
const config: CodeAnalyzerConfig = this.dependencies.configFactory.create(input['config-file']);
3535
const logWriter: LogFileWriter = await LogFileWriter.fromConfig(config);
36+
this.dependencies.actionSummaryViewer.viewPreExecutionSummary(logWriter.getLogDestination());
3637
// We always add a Logger Listener to the appropriate listeners list, because we should Always Be Logging.
3738
this.dependencies.logEventListeners.push(new LogEventLogger(logWriter));
3839
const core: CodeAnalyzer = new CodeAnalyzer(config);
@@ -60,7 +61,7 @@ export class RulesAction {
6061
const rules: Rule[] = core.getEngineNames().flatMap(name => ruleSelection.getRulesFor(name));
6162

6263
this.dependencies.viewer.view(rules);
63-
this.dependencies.actionSummaryViewer.view(ruleSelection, logWriter.getLogDestination());
64+
this.dependencies.actionSummaryViewer.viewPostExecutionSummary(ruleSelection, logWriter.getLogDestination());
6465
}
6566

6667
public static createAction(dependencies: RulesDependencies): RulesAction {

src/lib/actions/RunAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class RunAction {
5050
public async execute(input: RunInput): Promise<void> {
5151
const config: CodeAnalyzerConfig = this.dependencies.configFactory.create(input['config-file']);
5252
const logWriter: LogFileWriter = await LogFileWriter.fromConfig(config);
53+
this.dependencies.actionSummaryViewer.viewPreExecutionSummary(logWriter.getLogDestination());
5354
// We always add a Logger Listener to the appropriate listeners list, because we should Always Be Logging.
5455
this.dependencies.logEventListeners.push(new LogEventLogger(logWriter));
5556
const core: CodeAnalyzer = new CodeAnalyzer(config);
@@ -80,7 +81,7 @@ export class RunAction {
8081
this.dependencies.logEventListeners.forEach(listener => listener.stopListening());
8182
this.dependencies.writer.write(results);
8283
this.dependencies.resultsViewer.view(results);
83-
this.dependencies.actionSummaryViewer.view(results, logWriter.getLogDestination(), input['output-file']);
84+
this.dependencies.actionSummaryViewer.viewPostExecutionSummary(results, logWriter.getLogDestination(), input['output-file']);
8485

8586
const thresholdValue = input['severity-threshold'];
8687
if (thresholdValue) {

src/lib/viewers/ActionSummaryViewer.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ abstract class AbstractActionSummaryViewer {
1010
this.display = display;
1111
}
1212

13+
public viewPreExecutionSummary(logFile: string): void {
14+
// Start with separator to cleanly break from anything that's already been logged.
15+
this.displayLineSeparator();
16+
this.display.displayLog(getMessage(BundleName.ActionSummaryViewer, 'common.streaming-logs-to'));
17+
this.display.displayLog(indent(logFile));
18+
// End with a separator to cleanly break with anything that comes next.
19+
this.displayLineSeparator();
20+
}
21+
1322
protected displaySummaryHeader(): void {
1423
this.display.displayLog(toStyledHeader(getMessage(BundleName.ActionSummaryViewer, 'common.summary-header')));
1524
}
@@ -29,7 +38,9 @@ export class ConfigActionSummaryViewer extends AbstractActionSummaryViewer {
2938
super(display);
3039
}
3140

32-
public view(logFile: string, outfile?: string): void {
41+
public viewPostExecutionSummary(logFile: string, outfile?: string): void {
42+
// Start with separator to cleanly break from anything that's already been logged.
43+
this.displayLineSeparator();
3344
this.displaySummaryHeader();
3445
this.displayLineSeparator();
3546

@@ -52,7 +63,7 @@ export class RulesActionSummaryViewer extends AbstractActionSummaryViewer {
5263
super(display);
5364
}
5465

55-
public view(ruleSelection: RuleSelection, logFile: string): void {
66+
public viewPostExecutionSummary(ruleSelection: RuleSelection, logFile: string): void {
5667
// Start with separator to cleanly break from anything that's already been logged.
5768
this.displayLineSeparator();
5869
this.displaySummaryHeader();
@@ -82,7 +93,7 @@ export class RunActionSummaryViewer extends AbstractActionSummaryViewer {
8293
super(display);
8394
}
8495

85-
public view(results: RunResults, logFile: string, outfiles: string[]): void {
96+
public viewPostExecutionSummary(results: RunResults, logFile: string, outfiles: string[]): void {
8697
// Start with separator to cleanly break from anything that's already been logged.
8798
this.displayLineSeparator();
8899
this.displaySummaryHeader();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
=== Summary
23

34
Additional log information written to:

test/fixtures/comparison-files/lib/actions/ConfigAction.test.ts/action-summaries/outfile-created.txt.goldfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
=== Summary
23

34
Configuration written to:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Streaming logs in real time to:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Streaming logs in real time to:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Streaming logs in real time to:

0 commit comments

Comments
 (0)