diff --git a/cmd/root.go b/cmd/root.go index bb290ba..238f84a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -50,6 +50,7 @@ func initConfig() { } configPath := filepath.Join(configDir, "config.yaml") viper.SetConfigFile(configPath) + config.CreateDefaultConfigFile(configPath) if err := viper.ReadInConfig(); err != nil { fmt.Fprintf(os.Stderr, "error, couldn't read config file: %v\n", err) os.Exit(1) @@ -75,8 +76,6 @@ func initConfig() { logLevel = zapcore.InfoLevel } utils.InitializeLogger(logLevel, filepath.Join(configDir, "ytui.log")) - utils.Logger.Info("Initializing configuration...") - config.CreateDefaultConfigFile(configPath) utils.Logger.Info("Initialized configuration.") } diff --git a/pkg/config/config.go b/pkg/config/config.go index b08198e..085b148 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -18,11 +18,10 @@ type Config struct { // Creates the YAML config file func CreateDefaultConfigFile(filePath string) { // Struct with empty channels list - utils.Logger.Info("Config file set.", zap.String("filePath", filePath)) // Get user's home directory homeDir, err := os.UserHomeDir() if err != nil { - utils.Logger.Error("Failed to get home directory.", zap.Error(err)) + fmt.Fprintf(os.Stderr, "error, couldn't get home directory: %v\n", err) return } downloadDir := filepath.Join(homeDir, "Videos", "YouTube")