refactor(log): rename log initialization function for clarity

Ayman Bagabas created

Change summary

internal/config/load.go    | 8 ++------
internal/fsext/fileutil.go | 4 ++--
internal/log/log.go        | 4 ++--
3 files changed, 6 insertions(+), 10 deletions(-)

Detailed changes

internal/config/load.go 🔗

@@ -52,16 +52,12 @@ func Load(workingDir string, debug bool) (*Config, error) {
 		cfg.Options.Debug = true
 	}
 
-	// Init logs
-	log.Init(
+	// Setup logs
+	log.Setup(
 		filepath.Join(cfg.Options.DataDirectory, "logs", fmt.Sprintf("%s.log", appName)),
 		cfg.Options.Debug,
 	)
 
-	if err != nil {
-		return nil, fmt.Errorf("failed to load config: %w", err)
-	}
-
 	// Load known providers, this loads the config from fur
 	providers, err := LoadProviders(client.New())
 	if err != nil || len(providers) == 0 {

internal/fsext/fileutil.go 🔗

@@ -26,13 +26,13 @@ func init() {
 	var err error
 	rgPath, err = exec.LookPath("rg")
 	if err != nil {
-		if log.IsInitialized() {
+		if log.Initialized() {
 			slog.Warn("Ripgrep (rg) not found in $PATH. Some features might be limited or slower.")
 		}
 	}
 	fzfPath, err = exec.LookPath("fzf")
 	if err != nil {
-		if log.IsInitialized() {
+		if log.Initialized() {
 			slog.Warn("FZF not found in $PATH. Some features might be limited or slower.")
 		}
 	}

internal/log/log.go 🔗

@@ -17,7 +17,7 @@ var (
 	initialized atomic.Bool
 )
 
-func Init(logFile string, debug bool) {
+func Setup(logFile string, debug bool) {
 	initOnce.Do(func() {
 		logRotator := &lumberjack.Logger{
 			Filename:   logFile,
@@ -42,7 +42,7 @@ func Init(logFile string, debug bool) {
 	})
 }
 
-func IsInitialized() bool {
+func Initialized() bool {
 	return initialized.Load()
 }