Skip to content

✨ Better progress logging#376

Merged
wwilsman merged 6 commits intomasterfrom
ww/logger-progress
Jun 18, 2021
Merged

✨ Better progress logging#376
wwilsman merged 6 commits intomasterfrom
ww/logger-progress

Conversation

@wwilsman
Copy link
Copy Markdown
Contributor

@wwilsman wwilsman commented Jun 18, 2021

Purpose

There are two logs in particular that would be nice to have some progress associated with them. The processing snapshot queue log and the snapshot uploading queue log.

When SDKs such as Storybook or the snapshot command quickly take and process snapshots via asset discovery, the end result could be waiting for hundreds of snapshots to upload. To prevent clogging up processes with hundreds of in-flight requests at once, uploads are queued just as asset discovery is.

This results in a single log at the end of snapshot processing, before finalizing the build, when snapshots are uploading: Waiting for X snapshots to finish uploading. With #369, the message was changed to be more generic: Uploading snapshots.... Which is arguably less helpful, but in either case the CLI could be waiting for up to a minute while snapshots are uploaded. Meanwhile there is no feedback from the user's perspective.

Approach

During the refactor, while updating the CLI build plugin to work with client changes, I noticed that the code we use to log progress for the wait command was fairly simple and straightforward; and could be adapted to the above use case. The core pieces of progress logging code was moved into a new logger.progress() method and exposed for loggers. This method will not capture message to the internal log store since it is meant for visual purposes and not for debugging.

Where the wait command would always clear the line and not log progress before finished or failed logs were printed, we can take a slightly different approach to achieve the same effect. Rather than always clear the entire line, we can clear the line to the right of the cursor after printing a new message over the existing line. This helps to prevent some flicker between when the line was cleared and when new logs are printed.

For the snapshot queue logs, snapshots can continue to be taken once the queue is awaited one. The build will only be finalized once both the snapshot and upload queues have completely emptied. Because other logs can be printed while waiting on the snapshot queue, a persist option can be provided which will re-print the progress log after other logs clear it.

I also updated the install script progress logger to use our new method. Likewise with the build command that inspired the method, and even the browser revision script.

Preview

preview.mp4

(sped up a little for brevity)

@wwilsman wwilsman added the ✨ enhancement New feature or request label Jun 18, 2021
@wwilsman wwilsman requested a review from Robdel12 June 18, 2021 21:26
@wwilsman wwilsman force-pushed the ww/logger-progress branch from 1f08b2c to f1206ba Compare June 18, 2021 21:54
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drops a dependency and makes the UX better? You’re on a roll 🏁

@wwilsman wwilsman enabled auto-merge (squash) June 18, 2021 22:05
@wwilsman wwilsman merged commit 13acc94 into master Jun 18, 2021
@wwilsman wwilsman deleted the ww/logger-progress branch June 18, 2021 22:05
samarsault pushed a commit that referenced this pull request Mar 3, 2023
Bumps [eslint](https://github.com/eslint/eslint) from 7.29.0 to 7.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.29.0...v7.30.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants