Skip to content

Commit

Permalink
chore: only emit file logs in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Sep 16, 2024
1 parent d5c2176 commit bf62287
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions forge/cli/tui/ci/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ci

import (
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
Expand Down Expand Up @@ -107,11 +108,19 @@ func Run(scanPath string,
local bool,
opts ...earthly.EarthlyExecutorOption,
) error {
logger, f, err := tui.NewLogger()
if err != nil {
return err
var logger *slog.Logger
if _, ok := os.LookupEnv("DEBUG"); ok {
var err error
var f *os.File

logger, f, err = tui.NewLogger()
if err != nil {
return err
}
defer f.Close()
} else {
logger = slog.New(slog.NewTextHandler(io.Discard, nil))
}
defer f.Close()

loader := project.NewDefaultProjectLoader(
false,
Expand All @@ -121,7 +130,7 @@ func Run(scanPath string,
)

if scanPath == "" {
scanPath, err = findRoot(".", logger)
scanPath, err := findRoot(".", logger)
if err != nil {
return fmt.Errorf("failed to find root of git repository: %w", err)
}
Expand Down

0 comments on commit bf62287

Please sign in to comment.