Fix up logging a bit
This commit is contained in:
21
main.go
21
main.go
@@ -35,6 +35,7 @@ type ExtData struct {
|
||||
}
|
||||
|
||||
var debug bool
|
||||
|
||||
func main() {
|
||||
raw := flag.Bool("r", false, "More application friendly output")
|
||||
debugF := flag.Bool("d", false, "Debug mode")
|
||||
@@ -48,14 +49,10 @@ func main() {
|
||||
if debug {
|
||||
log.Printf("Scanning directory: %s", dir)
|
||||
}
|
||||
//log.Printf("%#v", IsStringBinary("using RimWorld;"))
|
||||
//return
|
||||
|
||||
files := make(chan string, 10000)
|
||||
//status := make(chan error)
|
||||
|
||||
//go GetSyncFilesRecursively(dir, files, status)
|
||||
files <- "CompRegisterAlternateGraphic.cs"
|
||||
status := make(chan error)
|
||||
go GetSyncFilesRecursively(dir, files, status)
|
||||
|
||||
extensionTypeCount := sync.Map{}
|
||||
wg := sync.WaitGroup{}
|
||||
@@ -63,6 +60,9 @@ func main() {
|
||||
wg.Add(1)
|
||||
go func(file string) {
|
||||
defer wg.Done()
|
||||
if debug {
|
||||
log.Printf("Processing file: %s", file) // Log the file being processed
|
||||
}
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
if debug {
|
||||
@@ -70,6 +70,7 @@ func main() {
|
||||
}
|
||||
return
|
||||
}
|
||||
defer f.Close() // Ensure the file is closed after processing
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
if scanner.Scan() {
|
||||
@@ -78,12 +79,12 @@ func main() {
|
||||
if IsStringBinary(scanner.Text()) {
|
||||
extData.(*ExtData).binaryCount++
|
||||
if debug {
|
||||
log.Printf("Binary file: %s (%s)", file, ext)
|
||||
log.Printf("Binary file detected: %s (%s)", file, ext) // Log binary file detection
|
||||
}
|
||||
} else {
|
||||
extData.(*ExtData).textCount++
|
||||
if debug {
|
||||
log.Printf("Text file: %s (%s)", file, ext)
|
||||
log.Printf("Text file detected: %s (%s)", file, ext) // Log text file detection
|
||||
}
|
||||
}
|
||||
} else if err := scanner.Err(); err != nil {
|
||||
@@ -91,8 +92,6 @@ func main() {
|
||||
log.Printf("Error reading line from file %s: %v", file, err)
|
||||
}
|
||||
}
|
||||
|
||||
f.Close()
|
||||
}(file)
|
||||
}
|
||||
wg.Wait()
|
||||
@@ -106,9 +105,11 @@ func main() {
|
||||
if *raw {
|
||||
fmt.Println(extData.ext)
|
||||
} else {
|
||||
if debug {
|
||||
log.Printf("Extension: %q, Binary Count: %d, Text Count: %d", extData.ext, extData.binaryCount, extData.textCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user