Add Zap logging framework with structured logging for Echo and Grafana

This commit is contained in:
2026-05-20 22:29:45 +02:00
parent 82252ce1ff
commit 37909139de
7 changed files with 64 additions and 37 deletions
+5 -5
View File
@@ -2,8 +2,8 @@ package server
import (
"github.com/labstack/echo/v5"
"log"
"music-server/internal/backend"
"music-server/internal/logging"
"net/http"
)
@@ -23,7 +23,7 @@ func NewDownloadHandler() *DownloadHandler {
// @Success 200 {string} string
// @Router /download [get]
func (d *DownloadHandler) checkLatest(ctx *echo.Context) error {
log.Println("Checking latest version")
logging.GetLogger().Info("Checking latest version")
latest := backend.CheckLatest()
return ctx.JSON(http.StatusOK, latest)
}
@@ -37,7 +37,7 @@ func (d *DownloadHandler) checkLatest(ctx *echo.Context) error {
// @Success 200 {array} string
// @Router /download/list [get]
func (d *DownloadHandler) listAssetsOfLatest(ctx *echo.Context) error {
log.Println("Listing assets")
logging.GetLogger().Info("Listing assets")
assets := backend.ListAssetsOfLatest()
return ctx.JSON(http.StatusOK, assets)
}
@@ -50,7 +50,7 @@ func (d *DownloadHandler) listAssetsOfLatest(ctx *echo.Context) error {
// @Success 302 {string} string
// @Router /download/windows [get]
func (d *DownloadHandler) downloadLatestWindows(ctx *echo.Context) error {
log.Println("Downloading latest windows")
logging.GetLogger().Info("Downloading latest windows")
asset := backend.DownloadLatestWindows()
ctx.Response().Header().Set("Content-Type", "application/octet-stream")
return ctx.Redirect(http.StatusFound, asset)
@@ -64,7 +64,7 @@ func (d *DownloadHandler) downloadLatestWindows(ctx *echo.Context) error {
// @Success 302 {string} string
// @Router /download/linux [get]
func (d *DownloadHandler) downloadLatestLinux(ctx *echo.Context) error {
log.Println("Downloading latest linux")
logging.GetLogger().Info("Downloading latest linux")
asset := backend.DownloadLatestLinux()
ctx.Response().Header().Set("Content-Type", "application/octet-stream")
return ctx.Redirect(http.StatusFound, asset)