-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,302 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {Event} from '../event.js'; | ||
import {Logger} from './logger.js'; | ||
import {WriteoverLine} from './quiet/writeover-line.js'; | ||
import {RunTracker, noChange, nothing} from './quiet/run-tracker.js'; | ||
|
||
/** | ||
* A {@link Logger} that prints less to the console. | ||
* | ||
* While running, it prints a single line of status text with information about | ||
* how the run is progressing. When the run is complete, it prints a one line | ||
* summary of the results if successful, and logs failures with the | ||
* corresponding script's stderr/stdout if something went wrong. | ||
*/ | ||
export class QuietLogger implements Logger { | ||
private runTracker; | ||
private readonly _rootPackage: string; | ||
private readonly _writeoverLine = new WriteoverLine(); | ||
|
||
constructor(rootPackage: string) { | ||
this._rootPackage = rootPackage; | ||
this.runTracker = new RunTracker(this._rootPackage, this._writeoverLine); | ||
} | ||
|
||
printMetrics() { | ||
this._writeoverLine.clearAndStopSpinner(); | ||
this.runTracker.printSummary(); | ||
} | ||
|
||
log(event: Event): void { | ||
if (event.type === 'info' && event.detail === 'watch-run-start') { | ||
this.runTracker = this.runTracker.makeInstanceForNewRun(); | ||
} | ||
const line = this.runTracker.getUpdatedMessageAfterEvent(event); | ||
if (line === noChange) { | ||
// nothing to do | ||
} else if (line === nothing) { | ||
this._writeoverLine.clearAndStopSpinner(); | ||
} else { | ||
this._writeoverLine.writeLine(line); | ||
} | ||
if (event.type === 'info' && event.detail === 'watch-run-end') { | ||
this.printMetrics(); | ||
} | ||
} | ||
|
||
getWatchLogger(): Logger { | ||
return this; | ||
} | ||
} |
Oops, something went wrong.