1
0

chore(web): use logger directly

(cherry picked from commit 6fb314b326d530322f1a2e674f250a265268082c)
This commit is contained in:
kolaente
2024-09-01 19:30:09 +02:00
parent fe44b7d473
commit a2ef74cade
8 changed files with 24 additions and 57 deletions

View File

@ -25,6 +25,7 @@ import (
vconfig "code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/modules/auth"
"github.com/labstack/echo/v4"
@ -42,7 +43,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
// Get the object & bind params to struct
if err := ctx.Bind(currentStruct); err != nil {
config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error())
log.Debugf("Invalid model error. Internal error was: %s", err.Error())
var he *echo.HTTPError
if errors.As(err, &he) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message))
@ -57,7 +58,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
}
pageNumber, err := strconv.Atoi(page)
if err != nil {
config.LoggingProvider.Error(err.Error())
log.Error(err.Error())
return echo.NewHTTPError(http.StatusBadRequest, "Bad page requested.")
}
if pageNumber < 0 {
@ -72,7 +73,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
if perPage != "" {
perPageNumber, err = strconv.Atoi(perPage)
if err != nil {
config.LoggingProvider.Error(err.Error())
log.Error(err.Error())
return echo.NewHTTPError(http.StatusBadRequest, "Bad per page amount requested.")
}
}
@ -92,7 +93,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
defer func() {
err = s.Close()
if err != nil {
config.LoggingProvider.Errorf("Could not close session: %s", err)
log.Errorf("Could not close session: %s", err)
}
}()