Skip to content
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

add --output-logs= option to turbo CLI #822

Merged
merged 14 commits into from
Mar 17, 2022
Merged

add --output-logs= option to turbo CLI #822

merged 14 commits into from
Mar 17, 2022

Conversation

chelkyl
Copy link
Contributor

@chelkyl chelkyl commented Mar 4, 2022

  • Adds --output-logs option with a few mode options to control output logs of tasks run by turbo run build
  • full is default and shows all tasks' process output
  • hash-only only outputs the hash line which has cache <miss|hit>, <executing|replaying output> <hash>
  • new-only shows all process output for tasks that have not been cached and only the hash line for cached tasks
  • none hides all tasks' process output

Usage:
turbo run build --output-logs=new-only

Without --output-logs or --output-logs=full
image

With --output-logs=hash-only
image

With --output-logs=new-only
image

With --output-logs=none
image

Closes #364

@vercel
Copy link

vercel bot commented Mar 4, 2022

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

A member of the Team first needs to authorize it.

@dcherman
Copy link

dcherman commented Mar 4, 2022

As a thought, can we also add turbo logs <hash> as a way to re-play logs from cached builds? That way if you do choose to use this flag, you still have a way of inspecting the logs from the completed builds if needed since you'd have the hashes.

@weyert
Copy link
Contributor

weyert commented Mar 4, 2022

I am wondering if something like similar to docker's --progress` flag makes more sense here?

--progress | auto | Set type of progress output (auto, plain, tty). Use plain to show container output

@jlarmstrongiv
Copy link

Wow, this is exactly what I need 😄 can’t wait to see it merged

I think @dcherman’s idea is an interesting. All logs are saved in the node_modules/.cache/turbo/<hash>/.turbo/turbo-<command>.log if you need to find it in the meantime.

@chelkyl
Copy link
Contributor Author

chelkyl commented Mar 5, 2022

I am wondering if something like similar to docker's --progress` flag makes more sense here?

--progress | auto | Set type of progress output (auto, plain, tty). Use plain to show container output

@weyert That does make a lot of sense! Refactoring.

@chelkyl chelkyl changed the title add --silence-cached-logs flag to turbo CLI add --progress=reduced option to turbo CLI Mar 5, 2022
chelkyl added 2 commits March 5, 2022 01:14
CLI option to hide logs of all cached tasks
less single-feature flags and more expandable
@chelkyl
Copy link
Contributor Author

chelkyl commented Mar 5, 2022

As a thought, can we also add turbo logs <hash> as a way to re-play logs from cached builds? That way if you do choose to use this flag, you still have a way of inspecting the logs from the completed builds if needed since you'd have the hashes.

@dcherman Great idea! I'll see what can be done and what other features this command could have.

@chelkyl chelkyl mentioned this pull request Mar 7, 2022
7 tasks
@weyert
Copy link
Contributor

weyert commented Mar 11, 2022

Nice, liking this. How can we progress this PR? @gsoltis

@gsoltis
Copy link
Contributor

gsoltis commented Mar 11, 2022

I like the idea, but I'm a little concerned about the flag name and option values. As I understand it, this is intended to control the behavior of logging when a cache hit occurs. The various options are "replay the logs", "don't replay the logs", and "replay just the first line that shows a cache hit". Does that seem like an accurate summary?

--progress on its own doesn't, at least to me, suggest logs behavior. Maybe there's another term we could use? Something like --cached-logs=[full|silent|name-only] or something like that? Definitely open to suggestions on this.

@chelkyl chelkyl changed the title add --progress=reduced option to turbo CLI add --output-logs= option to turbo CLI Mar 13, 2022
@chelkyl
Copy link
Contributor Author

chelkyl commented Mar 13, 2022

I like the idea, but I'm a little concerned about the flag name and option values. As I understand it, this is intended to control the behavior of logging when a cache hit occurs. The various options are "replay the logs", "don't replay the logs", and "replay just the first line that shows a cache hit". Does that seem like an accurate summary?

@gsoltis Previously, the --progress option only had 2 modes, "replay the logs" and "replay just the first line that shows a cache hit".

--progress on its own doesn't, at least to me, suggest logs behavior. Maybe there's another term we could use? Something like --cached-logs=[full|silent|name-only] or something like that? Definitely open to suggestions on this.

It was based on what docker provides and I wanted to keep it to a single word but I agree that it could be clearer! I have renamed it to --output-logs and added more functionality to control both cached and non-cached task output.
See the updated description and let me know what you think!

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.

This is coming along!

Can you also resolve any merge conflicts?

dryRun bool
dryRunJson bool
only bool
// Task logs output modes (cached and not cached tasks):
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a good candidate for an enum

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! Let me know if you prefer other names/values

// full - show all,
// hash - only show task hash,
// none - show nothing
cachedOutputLogsMode string
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe cacheHitLogsMode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! Done

// hash - only show task hash,
// none - show nothing
cachedOutputLogsMode string
notCachedOutputLogsMode string
Copy link
Contributor

Choose a reason for hiding this comment

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

cacheMissLogsMode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! Done

@@ -559,6 +572,24 @@ func parseRunArgs(args []string, output cli.Ui) (*RunOptions, error) {
includDepsSet = true
case strings.HasPrefix(arg, "--only"):
runOptions.only = true
case strings.HasPrefix(arg, "--output-logs"):
Copy link
Contributor

Choose a reason for hiding this comment

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

include =, since we're about to use it in the calculation on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Fixed

@@ -559,6 +572,24 @@ func parseRunArgs(args []string, output cli.Ui) (*RunOptions, error) {
includDepsSet = true
case strings.HasPrefix(arg, "--only"):
runOptions.only = true
case strings.HasPrefix(arg, "--output-logs"):
outputLogsMode := arg[len("--output-logs="):]
if len(outputLogsMode) > 0 {
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 this check, which will then print out a warning on an empty flag value

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 makes sense to me! Done

@kodiakhq kodiakhq bot merged commit 5522a20 into vercel:main Mar 17, 2022
@chelkyl
Copy link
Contributor Author

chelkyl commented Mar 17, 2022

Thanks!

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.

Silence cache hit logs
5 participants