fix: use silent logger in TUI mode to prevent console conflicts
This commit is contained in:
@@ -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)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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...)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user