Skip to content

Commit

Permalink
feat(olog): use texthandler in tests (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWinterman authored Oct 10, 2024
1 parent bac5b27 commit e706de0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/olog/default_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"runtime/debug"
"sync/atomic"
"testing"

charmlog "github.com/charmbracelet/log"

Expand Down Expand Up @@ -59,7 +60,13 @@ func determineMainModule() {
// is a `slog.TextHandler`. Otherwise, the default handler is the
// `slog.JSONHandler`.
func determineDefaultHandler() {
if testing.Testing() {
defaultHandler.Store(int32(TextHandler))
return
}

out, ok := defaultOut.(*os.File)

if !ok {
// If the default output is not a file, then we can't
// determine if it's a TTY or not. So, we default to JSON.
Expand Down

0 comments on commit e706de0

Please sign in to comment.