Fix up logging a little
This commit is contained in:
15
util.go
15
util.go
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -33,12 +32,12 @@ func NormalizePath(input, workdir string) string {
|
||||
input = strings.ReplaceAll(input, "\"", "")
|
||||
|
||||
if !filepath.IsAbs(input) {
|
||||
log.Printf("Input '%s' is not absolute, prepending work dir '%s'", input, workdir)
|
||||
LogInfo("Input '%s' is not absolute, prepending work dir '%s'", input, workdir)
|
||||
var err error
|
||||
input = filepath.Join(workdir, input)
|
||||
input, err = filepath.Abs(input)
|
||||
if err != nil {
|
||||
log.Printf("Failed to get absolute path for %s%s%s: %s%+v%s", SourceColor, input, DefaultColor, ErrorColor, err, DefaultColor)
|
||||
LogError("Failed to get absolute path for %s: %v", FormatSourcePath(input), err)
|
||||
return input
|
||||
}
|
||||
}
|
||||
@@ -157,15 +156,17 @@ func GetSyncFilesRecursively(input string, output chan string, status chan error
|
||||
|
||||
<-allDone
|
||||
|
||||
log.Printf("Files processed: %d; Folders processed: %d",
|
||||
atomic.LoadInt32(&filesProcessed),
|
||||
atomic.LoadInt32(&foldersProcessed))
|
||||
if atomic.LoadInt32(&filesProcessed) > 0 {
|
||||
LogInfo("Files processed: %d; Folders processed: %d",
|
||||
atomic.LoadInt32(&filesProcessed),
|
||||
atomic.LoadInt32(&foldersProcessed))
|
||||
}
|
||||
}
|
||||
|
||||
func processDirectory(directory string, directories chan<- string, output chan<- string, filesProcessed *int32) {
|
||||
files, err := os.ReadDir(directory)
|
||||
if err != nil {
|
||||
log.Printf("Error reading directory %s: %+v", directory, err)
|
||||
LogError("Error reading directory %s: %v", directory, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user