Skip to content

Commit 31a7a1c

Browse files
committed
feat: create log file for better reports
1 parent cf744ee commit 31a7a1c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"github.com/DanielFillol/DataJUD_API_CALLER/csv"
55
"github.com/DanielFillol/DataJUD_API_CALLER/request"
6+
"io"
67
"log"
8+
"os"
79
"time"
810
)
911

@@ -26,6 +28,18 @@ func main() {
2628
log.Fatal("Error loading requests from CSV: ", err)
2729
}
2830

31+
// Setup Log file
32+
logFile, err := os.Create("output.log.txt")
33+
if err != nil {
34+
log.Fatal("Failed to open log file:", err)
35+
}
36+
defer logFile.Close()
37+
38+
// Create a multi-writer that writes to both the file and os.Stdout (terminal)
39+
multiWriter := io.MultiWriter(os.Stdout, logFile)
40+
41+
log.SetOutput(multiWriter)
42+
2943
// Make API requests asynchronously
3044
start := time.Now()
3145
log.Println("Starting API calls...")

0 commit comments

Comments
 (0)