perf: use logger instead of fmt

This commit is contained in:
Antoine Aflalo
2024-08-27 14:58:34 -04:00
parent cd9bd387fa
commit 85cefbe8b3

View File

@@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/cbz" "github.com/belphemur/CBZOptimizer/cbz"
"github.com/belphemur/CBZOptimizer/converter" "github.com/belphemur/CBZOptimizer/converter"
"log"
"strings" "strings"
) )
// Optimize optimizes a CBZ file using the specified converter. // Optimize optimizes a CBZ file using the specified converter.
func Optimize(chapterConverter converter.Converter, path string, quality uint8, override bool) error { func Optimize(chapterConverter converter.Converter, path string, quality uint8, override bool) error {
fmt.Printf("Processing file: %s\n", path) log.Printf("Processing file: %s\n", path)
// Load the chapter // Load the chapter
chapter, err := cbz.LoadChapter(path) chapter, err := cbz.LoadChapter(path)
@@ -18,13 +19,13 @@ func Optimize(chapterConverter converter.Converter, path string, quality uint8,
} }
if chapter.IsConverted { if chapter.IsConverted {
fmt.Printf("Chapter already converted: %s\n", path) log.Printf("Chapter already converted: %s", path)
return nil return nil
} }
// Convert the chapter // Convert the chapter
convertedChapter, err := chapterConverter.ConvertChapter(chapter, quality, func(msg string) { convertedChapter, err := chapterConverter.ConvertChapter(chapter, quality, func(msg string) {
fmt.Println(msg) log.Printf("[%s]%s", path, msg)
}) })
if err != nil { if err != nil {
return fmt.Errorf("failed to convert chapter: %v", err) return fmt.Errorf("failed to convert chapter: %v", err)
@@ -41,7 +42,7 @@ func Optimize(chapterConverter converter.Converter, path string, quality uint8,
return fmt.Errorf("failed to write converted chapter: %v", err) return fmt.Errorf("failed to write converted chapter: %v", err)
} }
fmt.Printf("Converted file written to: %s\n", outputPath) log.Printf("Converted file written to: %s\n", outputPath)
return nil return nil
} }