Print a failed command's error once on stderr (closes #433)
check / check (push) Failing after 9m31s
check / check (push) Failing after 9m31s
A failed command printed its error twice on stderr: as an ERROR log record and as the final ERROR: line the README documents. The command handlers, a restore failure that ends the command and a failed blob upload now log that error at info level or not at all, so without --verbose or --debug only the final line appears. Model: opus-5-5
This commit was merged in pull request #451.
This commit is contained in:
1 parent
5f1f8c4f66
commit
6a8bb2f389
12 files changed
+247
-25
No files matched your search
@@ -37,9 +37,9 @@ func uploadTestBlob(ctx context.Context, store storage.Storer) error {
|
||||
}
|
||||
|
||||
// captureLog runs fn and returns what the logger wrote to stderr
|
||||
// meanwhile. The logger writes to the os.Stderr it finds when it is
|
||||
// initialized, so os.Stderr is pointed at a file first. Not
|
||||
// parallel-safe: os.Stderr and the logger are process-global.
|
||||
// meanwhile, at the --verbose level. The logger writes to the os.Stderr
|
||||
// it finds when it is initialized, so os.Stderr is pointed at a file
|
||||
// first. Not parallel-safe: os.Stderr and the logger are process-global.
|
||||
func captureLog(t *testing.T, fn func()) string {
|
||||
t.Helper()
|
||||
|
||||
@@ -53,7 +53,7 @@ func captureLog(t *testing.T, fn func()) string {
|
||||
previous := os.Stderr
|
||||
os.Stderr = stderrFile
|
||||
|
||||
log.Initialize(log.Config{})
|
||||
log.Initialize(log.Config{Verbose: true})
|
||||
|
||||
fn()
|
||||
|
||||
@@ -107,10 +107,10 @@ func TestInterruptedUploadIsNotLoggedAsError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// An upload that fails for any other reason is still logged as an error.
|
||||
// An upload that fails for any other reason is still logged.
|
||||
//
|
||||
//nolint:paralleltest // captureLog replaces os.Stderr
|
||||
func TestFailedUploadIsLoggedAsError(t *testing.T) {
|
||||
func TestFailedUploadIsLogged(t *testing.T) {
|
||||
inner, err := storage.NewFileStorer(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in new issue
Block a user