Skip to content

Commit

Permalink
Print Landscape logs on failure
Browse files Browse the repository at this point in the history
Or any other component which ends up using slogs
  • Loading branch information
EduardGomezEscandell committed Nov 20, 2023
1 parent ba96c94 commit 68f326f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions end-to-end/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io/fs"
"log"
"log/slog"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -48,6 +49,16 @@ func testSetup(t *testing.T) {
log.Printf("Cleanup: %v", err)
}
})

var out bytes.Buffer
h := slog.NewTextHandler(&out, &slog.HandlerOptions{Level: slog.LevelDebug})
slog.SetDefault(slog.New(h))

t.Cleanup(func() {
if t.Failed() {
fmt.Printf("==== SLOGS ====\n%s", out.String())
}
})
}

//nolint:revive // testing.T must precede the context
Expand Down

0 comments on commit 68f326f

Please sign in to comment.