Skip to content

Commit

Permalink
feat: create log file for better reports
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielFillol committed Oct 20, 2023
1 parent cf744ee commit 31a7a1c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package main
import (
"github.com/DanielFillol/DataJUD_API_CALLER/csv"
"github.com/DanielFillol/DataJUD_API_CALLER/request"
"io"
"log"
"os"
"time"
)

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

// Setup Log file
logFile, err := os.Create("output.log.txt")
if err != nil {
log.Fatal("Failed to open log file:", err)
}
defer logFile.Close()

// Create a multi-writer that writes to both the file and os.Stdout (terminal)
multiWriter := io.MultiWriter(os.Stdout, logFile)

log.SetOutput(multiWriter)

// Make API requests asynchronously
start := time.Now()
log.Println("Starting API calls...")
Expand Down

0 comments on commit 31a7a1c

Please sign in to comment.