erkexzcx / valetudopng

A Valetudo map renderer (ex Hypfer/ICantBelieveItsNotValetudo) for Home Assistant.
https://valetudo.cloud/
Apache License 2.0
39 stars 6 forks source link

Replaced log with slog, added debug levels and an option to have semi… #13

Open jonmol opened 3 months ago

jonmol commented 3 months ago

First off: Sorry for the massive PR. My intention was just to add a new endpoint spitting out some sane starter config for lovelace-xiaomi-vacuum-map-card as I was struggling with that. I ended up making some pretty large changes, hopefully adding a bit of stability while sticking to the code style of the repo. It should be relatively easy to cherry pick if you just want the new endpoint.

Replaced log with slog, added debug levels and an option to have semi-structured logs in json

Added graceful shutdown for MQTT and HTTP, just letting the main process die might lead to http not releasing the port

Changed the connection to MQTT a bit and added waitgroups for the go routines

The for loop in server.go was blocking so the function never listened for signals to shut down

Added a new debug endpoint which prints out a semi-decent configuration for lovelace-xiaomi-vacuum-map-card

erkexzcx commented 2 months ago

Hi. I will review this once I have some free time. Thank you!

erkexzcx commented 1 month ago

Impressive work. You fixed many "invisible" issues. I'll do some tests on my end and merge this. Meanwhile, I am considering doing some automated tests for this application... :thinking:

erkexzcx commented 1 month ago

The new log/slog package in Go 1.21 brings structured logging to the standard library.

I wasn't following Golang for a while, yet been developing in Golang :sweat_smile:. That's really really neat! Thank you!