Merge pull request #238 from BBVA/dependabot/docker/dot-github/go/golang-1.20.2

chore(deps): bump golang from 1.20.1 to 1.20.2 in /.github/go
This commit is contained in:
César Gallego Rodríguez
2023-03-19 19:05:15 +01:00
committed by GitHub
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
FROM golang:1.20.1 FROM golang:1.20.2
+13 -2
View File
@@ -22,6 +22,7 @@ import (
"net/http" "net/http"
"net/textproto" "net/textproto"
"strconv" "strconv"
"strings"
"github.com/BBVA/kapow/internal/logger" "github.com/BBVA/kapow/internal/logger"
"github.com/BBVA/kapow/internal/server/httperror" "github.com/BBVA/kapow/internal/server/httperror"
@@ -248,8 +249,18 @@ func setServerLog(w http.ResponseWriter, r *http.Request, h *model.Handler) {
} }
handlerId := mux.Vars(r)["handlerID"] handlerId := mux.Vars(r)["handlerID"]
if prefix := mux.Vars(r)["prefix"]; prefix == "" { if prefix := mux.Vars(r)["prefix"]; prefix == "" {
logger.L.Printf("%s %s\n", handlerId, msg) logger.L.Printf("%s %s\n", escapeString(handlerId), msg)
} else { } else {
logger.L.Printf("%s %s: %s\n", handlerId, prefix, msg) logger.L.Printf("%s %s: %s\n", escapeString(handlerId), escapeString(prefix), msg)
} }
} }
// function to scape strings in order to be printed in a Log
func escapeString(s string) string {
s = strings.Replace(s, "\n", "", -1)
s = strings.Replace(s, "\r", "", -1)
s = strings.Replace(s, "\t", "", -1)
s = strings.Replace(s, "\b", "", -1)
return s
}