Replace log with logrus for level based logging, add debug flag

This commit is contained in:
2023-12-15 06:40:10 -06:00
parent ca136634c9
commit b5ee5bec0c
7 changed files with 49 additions and 27 deletions

View File

@@ -5,9 +5,10 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
)
func Scan() {
@@ -15,7 +16,7 @@ func Scan() {
total := len(locations)
for i, location := range locations {
log.Printf("[%6.2f] Fetching \"%s\" ", float64(i+1)/float64(total)*100, location.name)
log.Debugf("[%6.2f] Fetching \"%s\" ", float64(i+1)/float64(total)*100, location.name)
body := fmt.Sprintf("propertyIdSelected=%d&propertySource=parking-snap", location.id)
req := BuildRequestWithBody("POST", "/register-get-vehicle-form", nil, bytes.NewBufferString(body))
@@ -42,8 +43,6 @@ func Scan() {
if err != nil {
panic(err)
}
log.Println("DONE")
} else if stats.Size() < 16 {
// File exists, but is empty
file, err := os.OpenFile(html_path, os.O_WRONLY, 0644)
@@ -56,10 +55,8 @@ func Scan() {
if err != nil {
panic(err)
}
log.Println("OVERWRITE")
} else {
// File exists and is not empty, do nothing
log.Println("SKIP")
}
}
}