change to use logging instead of print to stdout

This commit is contained in:
2023-04-03 12:00:01 +10:00
parent f2ac6097d6
commit 5cc67501d3
11 changed files with 88 additions and 87 deletions

View File

@@ -3,7 +3,7 @@ package controllers
import (
"ccsecrets/models"
"errors"
"fmt"
"log"
"net/http"
"github.com/gin-gonic/gin"
@@ -27,7 +27,7 @@ func StoreSecret(c *gin.Context) {
return
}
fmt.Printf("StoreSecret received JSON input '%v'\n", input)
log.Printf("StoreSecret received JSON input '%v'\n", input)
// Populate fields
s := models.Secret{}
@@ -55,7 +55,7 @@ func StoreSecret(c *gin.Context) {
}
if len(checkExists) > 0 {
fmt.Printf("StoreSecret not storing secret with '%d' already matching secrets.\n", len(checkExists))
log.Printf("StoreSecret not storing secret with '%d' already matching secrets.\n", len(checkExists))
c.JSON(http.StatusBadRequest, gin.H{"error": "StoreSecret attempting to store secret already defined. API calls for update/delete don't yet exist"})
return
}
@@ -86,7 +86,7 @@ func UpdateSecret(c *gin.Context) {
return
}
fmt.Printf("UpdateSecret received JSON input '%v'\n", input)
log.Printf("UpdateSecret received JSON input '%v'\n", input)
// Get the user and role id of the requestor
u, err := models.GetUserRoleFromToken(c)