这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: output line with --output-logs=new-only should reflect actual behavior #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 7, 2022

Conversation

chelkyl
Copy link
Contributor

@chelkyl chelkyl commented Mar 31, 2022

Closes #972

image

@vercel
Copy link

vercel bot commented Mar 31, 2022

@chelkyl is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Apr 1, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vercel/turbo-site/GT97RyaMS1iPVJCF6awEZE9WqdBt
✅ Preview: https://turbo-site-git-fork-chelkyl-chelkyl-fix-new-only-output.vercel.sh

@jaredpalmer
Copy link
Contributor

@chelkyl awesome job with these PRs! Can you send me either a Twitter or Discord DM?

@jaredpalmer
Copy link
Contributor

Need to update e2e.ts tests with updated string output

@chelkyl
Copy link
Contributor Author

chelkyl commented Apr 6, 2022

@jaredpalmer Thanks for the notice, fixed!
Sent you a DM on Discord (from username z...).

Copy link
Contributor

@gsoltis gsoltis left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this, I think the changes point to a need to do a little refactoring to make this a more straightforward change.

//Writing to Stdout only the "cache hit, replaying output" line
scan.Scan()
prefixUi.Output(ui.StripAnsi(string(scan.Bytes())))
prefixUi.Output(fmt.Sprintf("%scache hit, suppressing output %s", logPrefix, ui.Dim(hash)))
Copy link
Contributor

Choose a reason for hiding this comment

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

This line seems a little weird: we're outputting from something called prefixUi, but we're also manually adding a prefix.

I think we might want to refactor this a little to be less confusing. I think what's going on is the following:

  • the calling code has two Ui instances, one prefixed, one not
  • we're not actually passing in the prefixed one, because we expect the prefix to be in the logs already
  • we're then manually adding the prefix in the case where we are synthesizing a log line

Here's my proposal:

  • check the outputLogsMode before calling replayLogs.
  • If we're in 'NoLogs' mode, great, we're done
  • create a separate function to just output the cache hit for HashLogs mode. We're already not using the file contents in that case, so don't even open the file. Pass in the correct Ui instance that already has the prefix baked in (targetUi, I think). It doesn't even need to be in a goroutine, we could just call it directly. In fact, it might not even need to be function, it might even be just a single line
  • If we're in FullLogs mode, use the existing replayLogs
  • Remove the case for NoLogs in replayLogs

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That refactor really cleans it up. Thanks for the suggestion!

@chelkyl chelkyl requested a review from nathanhammond as a code owner April 6, 2022 22:08
by extracting output logs mode logic out
@chelkyl chelkyl force-pushed the chelkyl/fix-new-only-output branch from 05c132f to 329bae5 Compare April 6, 2022 22:09
chelkyl added 2 commits April 6, 2022 17:19
from feat(colors): add options for forcing color/no-color
Copy link
Contributor

@gsoltis gsoltis left a comment

Choose a reason for hiding this comment

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

Awesome, this is looking pretty good. Just a couple more minor suggestions to clean this up a little more.

case FullLogs:
if e.rs.Opts.stream && fs.FileExists(filepath.Join(e.rs.Opts.cwd, logFileName)) {
e.logReplayWaitGroup.Add(1)
go replayLogs(targetLogger, e.ui, e.rs.Opts, logFileName, hash, &e.logReplayWaitGroup, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize it was here earlier, but let's get rid of the false for silent too. I think this is the only place where replayLogs is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -796,7 +796,7 @@ func (c *RunCommand) executeDryRun(engine *core.Scheduler, g *completeGraph, rs
}

// Replay logs will try to replay logs back to the stdout
func replayLogs(logger hclog.Logger, prefixUi cli.Ui, runOptions *RunOptions, logFileName, hash string, wg *sync.WaitGroup, silent bool, outputLogsMode LogsMode) {
func replayLogs(logger hclog.Logger, prefixUi cli.Ui, runOptions *RunOptions, logFileName, hash string, wg *sync.WaitGroup, silent bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can drop silent, it's only ever hard-coded to false.

I think we also want to rename prefixUi, since it's not prefixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, done!

Copy link
Contributor

@gsoltis gsoltis left a comment

Choose a reason for hiding this comment

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

Nice work!

@vercel
Copy link

vercel bot commented Apr 7, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Updated Deployment Preview
turbo-site ✅ Deployed Apr 7, 2022 at 5:11PM (UTC) View on Vercel View Preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs shouldn't say "replaying output" when --output-logs suppresses the replayed output
3 participants