fix: use silent logger in TUI mode to prevent console conflicts

This commit is contained in:
2025-11-05 13:21:16 +00:00
parent 5bbccc3035
commit 9345950483
2 changed files with 18 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
"strings" "strings"
"time" "time"
"dbbackup/internal/logger"
"dbbackup/internal/tui" "dbbackup/internal/tui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -58,8 +59,9 @@ var interactiveCmd = &cobra.Command{
Long: `Start the interactive menu system for guided backup operations.`, Long: `Start the interactive menu system for guided backup operations.`,
Aliases: []string{"menu", "ui"}, Aliases: []string{"menu", "ui"},
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
// Start the interactive TUI // Start the interactive TUI with silent logger to prevent console output conflicts
return tui.RunInteractiveMenu(cfg, log) silentLog := logger.NewSilent()
return tui.RunInteractiveMenu(cfg, silentLog)
}, },
} }

View File

@@ -78,6 +78,20 @@ func New(level, format string) Logger {
} }
} }
// NewSilent creates a logger that discards all output (for TUI mode)
func NewSilent() Logger {
l := logrus.New()
l.SetLevel(logrus.InfoLevel)
l.SetOutput(io.Discard) // Discard all log output
l.SetFormatter(&CleanFormatter{})
return &logger{
logrus: l,
level: logrus.InfoLevel,
format: "text",
}
}
func (l *logger) Debug(msg string, args ...any) { func (l *logger) Debug(msg string, args ...any) {
l.logWithFields(logrus.DebugLevel, msg, args...) l.logWithFields(logrus.DebugLevel, msg, args...)
} }