implement structured logging

This commit is contained in:
Markus Muellner
2022-06-30 19:37:10 +02:00
committed by Benj Fassbind
parent 0c749922c9
commit 8e62195eb5
21 changed files with 558 additions and 54 deletions
+3 -3
View File
@@ -3,7 +3,6 @@ package api
import (
"fmt"
"log"
"net/http"
"sort"
"strconv"
@@ -15,6 +14,7 @@ import (
"github.com/aptly-dev/aptly/query"
"github.com/aptly-dev/aptly/task"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
)
// Lock order acquisition (canonical):
@@ -155,7 +155,7 @@ func maybeRunTaskInBackground(c *gin.Context, name string, resources []string, p
// Run this task in background if configured globally or per-request
background := truthy(c.DefaultQuery("_async", strconv.FormatBool(context.Config().AsyncAPI)))
if background {
log.Println("Executing task asynchronously")
log.Info().Msg("Executing task asynchronously")
task, conflictErr := runTaskInBackground(name, resources, proc)
if conflictErr != nil {
AbortWithJSONError(c, 409, conflictErr)
@@ -163,7 +163,7 @@ func maybeRunTaskInBackground(c *gin.Context, name string, resources []string, p
}
c.JSON(202, task)
} else {
log.Println("Executing task synchronously")
log.Info().Msg("Executing task synchronously")
out := context.Progress()
detail := task.Detail{}
retValue, err := proc(out, &detail)