-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add --log-prefix=none option #3851
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
Changes from all commits
cf82823
d403d76
4946261
2625400
f037561
7639bf9
d94d22b
242833d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| Setup | ||
| $ . ${TESTDIR}/../setup.sh | ||
| $ . ${TESTDIR}/setup.sh $(pwd) ./monorepo | ||
|
|
||
| # Run for the first time with --log-prefix=none | ||
| $ ${TURBO} run build --log-prefix=none | ||
| \xe2\x80\xa2 Packages in scope: app-a (esc) | ||
| \xe2\x80\xa2 Running build in 1 packages (esc) | ||
| \xe2\x80\xa2 Remote caching disabled (esc) | ||
| cache miss, executing 74eb1b46ce8b29d3 | ||
|
|
||
| \> build (re) | ||
| \> echo 'build app-a' (re) | ||
|
|
||
| build app-a | ||
|
|
||
| Tasks: 1 successful, 1 total | ||
| Cached: 0 cached, 1 total | ||
| Time:\s*[\.0-9]+m?s (re) | ||
|
|
||
| # Check that the cached logs don't have prefixes | ||
| $ cat app-a/.turbo/turbo-build.log | ||
|
|
||
| \> build (re) | ||
| \> echo 'build app-a' (re) | ||
|
|
||
| build app-a | ||
|
|
||
| # Running again should get a cache hit and no prefixes | ||
| $ ${TURBO} run build --log-prefix=none | ||
| \xe2\x80\xa2 Packages in scope: app-a (esc) | ||
| \xe2\x80\xa2 Running build in 1 packages (esc) | ||
| \xe2\x80\xa2 Remote caching disabled (esc) | ||
| cache miss, executing 3df2c74b2bfbc724 | ||
|
|
||
| \> build (re) | ||
| \> echo 'build app-a' (re) | ||
|
|
||
| build app-a | ||
|
|
||
| Tasks: 1 successful, 1 total | ||
| Cached: 0 cached, 1 total | ||
| Time:\s*[\.0-9]+m?s (re) | ||
|
|
||
| # Running again withuot `--log-prefix` should get a cache hit, but should print prefixes this time | ||
| $ ${TURBO} run build | ||
| \xe2\x80\xa2 Packages in scope: app-a (esc) | ||
| \xe2\x80\xa2 Running build in 1 packages (esc) | ||
| \xe2\x80\xa2 Remote caching disabled (esc) | ||
| app-a:build: cache hit, replaying output 3df2c74b2bfbc724 | ||
| app-a:build: | ||
| app-a:build: > build | ||
| app-a:build: > echo 'build app-a' | ||
| app-a:build: | ||
| app-a:build: build app-a | ||
|
|
||
| Tasks: 1 successful, 1 total | ||
| Cached: 1 cached, 1 total | ||
| Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) | ||
|
|
||
|
|
||
| # Running with bogus option | ||
| $ ${TURBO} run build --log-prefix=blah | ||
| ERROR invalid value 'blah' for '--log-prefix <LOG_PREFIX>' | ||
| [possible values: none] | ||
|
|
||
| For more information, try '--help'. | ||
|
|
||
| [1] | ||
|
|
||
| # Running with missing value for option | ||
| $ ${TURBO} run build --log-prefix | ||
| ERROR a value is required for '--log-prefix <LOG_PREFIX>' but none was supplied | ||
| [possible values: none] | ||
|
|
||
| For more information, try '--help'. | ||
|
|
||
| [1] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "app-a", | ||
| "scripts": { | ||
| "build": "echo 'build app-a'" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "monorepo", | ||
| "workspaces": [ | ||
| "app-*" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "pipeline": { | ||
| "build": {} | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) | ||
| TARGET_DIR=$1 | ||
| TEST_DIR=$2 | ||
| cp -a ${SCRIPT_DIR}/$TEST_DIR/. ${TARGET_DIR}/ | ||
| ${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,9 +151,6 @@ func (ec *execContext) logError(log hclog.Logger, prefix string, err error) { | |
| func (ec *execContext) exec(ctx gocontext.Context, packageTask *nodes.PackageTask, deps dag.Set) error { | ||
| cmdTime := time.Now() | ||
|
|
||
| prefix := packageTask.OutputPrefix(ec.isSinglePackage) | ||
| prettyPrefix := ec.colorCache.PrefixWithColor(packageTask.PackageName, prefix) | ||
|
|
||
| progressLogger := ec.logger.Named("") | ||
| progressLogger.Debug("start") | ||
|
|
||
|
|
@@ -177,6 +174,17 @@ func (ec *execContext) exec(ctx gocontext.Context, packageTask *nodes.PackageTas | |
| progressLogger.Debug("done", "status", "skipped", "duration", time.Since(cmdTime)) | ||
| return nil | ||
| } | ||
|
|
||
| var prefix string | ||
| var prettyPrefix string | ||
| if ec.rs.Opts.runOpts.logPrefix == "none" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
|
||
| prefix = "" | ||
| } else { | ||
| prefix = packageTask.OutputPrefix(ec.isSinglePackage) | ||
| } | ||
|
|
||
| prettyPrefix = ec.colorCache.PrefixWithColor(packageTask.PackageName, prefix) | ||
|
|
||
| // Cache --------------------------------------------- | ||
| taskCache := ec.runCache.TaskCache(packageTask, hash) | ||
| // Create a logger for replaying | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,4 +74,7 @@ type runOpts struct { | |
| graphFile string | ||
| noDaemon bool | ||
| singlePackage bool | ||
|
|
||
| // logPrefix controls whether we should print a prefix in task logs | ||
| logPrefix string | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into using an enum here instead of a string, but decided against it because:
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.