Logging Adjustments

This commit is contained in:
Fred Boniface 2023-08-11 15:33:18 +01:00
parent 3d5f755226
commit 43ebc5e4f3
2 changed files with 20 additions and 5 deletions

View File

@ -1,8 +1,14 @@
package imaging package imaging
import "image" import (
"fmt"
"image"
"git.fjla.uk/fred.boniface/map-dots/log"
)
func Generate(height, width int, style, format string, data []string) image.Image { func Generate(height, width int, style, format string, data []string) image.Image {
log.Msg.Debug("Image generation request: " + fmt.Sprint(width) + "x" + fmt.Sprint(height) + " " + format + " " + style)
img := createCanvas(width, height) img := createCanvas(width, height)
return img return img
} }

View File

@ -8,6 +8,9 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"time" "time"
"git.fjla.uk/fred.boniface/map-dots/imaging"
"git.fjla.uk/fred.boniface/map-dots/log"
) )
func Server() { func Server() {
@ -18,10 +21,12 @@ func Server() {
http.HandleFunc("/help/", handleHelpRequest) http.HandleFunc("/help/", handleHelpRequest)
serverAddr := "localhost:8198" // Set your desired server address serverAddr := "localhost:8198" // Set your desired server address
fmt.Printf("Server listening on http://%s\n", serverAddr) fmt.Printf("Starting server on http://%s\n", serverAddr)
log.Msg.Info("Starting server on http://" + serverAddr)
err := http.ListenAndServe(serverAddr, nil) err := http.ListenAndServe(serverAddr, nil)
if err != nil { if err != nil {
fmt.Printf("Error starting server: %s\n", err) fmt.Printf("Error starting server: %s\n", err)
log.Msg.Error("Server failed to start:" + err.Error())
} }
} }
@ -36,7 +41,11 @@ func handleTraccarRequest(w http.ResponseWriter, r *http.Request) {
return return
} }
fmt.Println(id, from, to, height, width, style, format) fmt.Println(id, from, to)
var nullArry []string
var _ = imaging.Generate(height, width, style, format, nullArry)
message := map[string]string{ message := map[string]string{
"status": "success", "status": "success",
@ -77,10 +86,10 @@ func validateAndProcessParams(queryValues url.Values) (string, string, string, i
to = time.Now().UTC().Format(time.RFC3339) to = time.Now().UTC().Format(time.RFC3339)
} }
if heightStr == "" { if heightStr == "" {
heightStr = "300" heightStr = "1080"
} }
if widthStr == "" { if widthStr == "" {
widthStr = "400" widthStr = "1920"
} }
if style == "" { if style == "" {
style = "circle" style = "circle"