-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Buffer BufferedLogger by newline to avoid log splitting #39288
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
|
|
@@ -580,10 +581,13 @@ func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger | |
| } | ||
| bufLogger.Printf(ctx, "Dependencies in %s:", phase) | ||
|
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. Could we please append Maybe we should also prepend it with "Runtime dependencies" ? Context: this way it would be easier to search in the cloud console "dependencies" and seeing the line that filters the dependenices + content. We should do the same for submission deps as well. Fine to do in a separate PR if you feel this is out of scope or file an issue if you'd rather not do this rn. |
||
| args = []string{"-m", "pip", "freeze", "--all"} | ||
| if err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...); err != nil { | ||
|
|
||
| var stdout bytes.Buffer | ||
| if err := execx.ExecuteEnvWithIO(nil, os.Stdin, &stdout, bufLogger, pythonVersion, args...); err != nil { | ||
|
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. Thanks, @shunping ! This PR allows for additional flexibility to retain logs and output them in a better form. My main worry is with the complexity a developer should reason about to get things right:
Do you think we could simplify this with better helpers? Perhaps with something like: // executeAndBatchLogs runs a command and batches its output into a single func executeAndBatchLogs(ctx context.Context, env map[string]string, bufLogger *tools.BufferedLogger, prog string, args ...string) error { // executeAndStreamLogs runs a command and streams both its standard output and WDYT? |
||
| bufLogger.FlushAtError(ctx) | ||
| } else { | ||
| bufLogger.FlushAtDebug(ctx) | ||
| bufLogger.Printf(ctx, "%s", stdout.String()) | ||
| } | ||
| return nil | ||
| } | ||
|
|
@@ -602,5 +606,3 @@ func logSubmissionEnvDependencies(ctx context.Context, bufLogger *tools.Buffered | |
| bufLogger.Printf(ctx, "%s", string(content)) | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.