Replace fmt.Println with server logger
This commit is contained in:
@ -127,7 +127,8 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
||||
newGoogleSetupJSON, _ := json.Marshal(user)
|
||||
err = app.Server.Cache.SetCache(r.Context(), "GoogleSetup:"+code, newGoogleSetupJSON, time.Minute*15)
|
||||
if err != nil {
|
||||
fmt.Println("Error setting up Google Setup:", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
app.Server.Logger.Error(err.Error())
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, fmt.Sprintf("/auth/google/setup/%s", code), http.StatusSeeOther)
|
||||
|
@ -117,16 +117,16 @@ func handlerWS(conn *websocket.Conn, userSession types.User) {
|
||||
_, message, err = conn.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
fmt.Println("Unexpected connection closure:", err)
|
||||
app.Server.Logger.Error("Unexpected connection closure:", err)
|
||||
} else {
|
||||
fmt.Println("Connection closed:", err)
|
||||
app.Server.Logger.Error("Connection closed:", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
var action WebsocketAction
|
||||
err = json.Unmarshal(message, &action)
|
||||
if err != nil {
|
||||
fmt.Println("Error unmarshalling WebsocketAction:", err)
|
||||
app.Server.Logger.Error("Error unmarshalling WebsocketAction:", err)
|
||||
sendErrorResponse(conn, action.Action)
|
||||
continue
|
||||
}
|
||||
@ -136,7 +136,7 @@ func handlerWS(conn *websocket.Conn, userSession types.User) {
|
||||
var uploadNewFile ActionUploadNewFile
|
||||
err = json.Unmarshal(message, &uploadNewFile)
|
||||
if err != nil {
|
||||
fmt.Println("Error unmarshalling ActionUploadNewFile:", err)
|
||||
app.Server.Logger.Error("Error unmarshalling ActionUploadNewFile:", err)
|
||||
sendErrorResponse(conn, action.Action)
|
||||
continue
|
||||
}
|
||||
@ -220,12 +220,12 @@ func sendErrorResponse(conn *websocket.Conn, action ActionType) {
|
||||
}
|
||||
marshal, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling error response:", err)
|
||||
app.Server.Logger.Error("Error marshalling error response:", err)
|
||||
return
|
||||
}
|
||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||
if err != nil {
|
||||
fmt.Println("Error writing error response:", err)
|
||||
app.Server.Logger.Error("Error writing error response:", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,12 +237,12 @@ func sendSuccessResponse(conn *websocket.Conn, action ActionType, response inter
|
||||
}
|
||||
marshal, err := json.Marshal(responseJSON)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling success response:", err)
|
||||
app.Server.Logger.Error("Error marshalling success response:", err)
|
||||
return
|
||||
}
|
||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||
if err != nil {
|
||||
fmt.Println("Error writing success response:", err)
|
||||
app.Server.Logger.Error("Error writing success response:", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,11 +255,11 @@ func sendSuccessResponseWithID(conn *websocket.Conn, action ActionType, response
|
||||
}
|
||||
marshal, err := json.Marshal(responseJSON)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling success response:", err)
|
||||
app.Server.Logger.Error("Error marshalling success response:", err)
|
||||
return
|
||||
}
|
||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||
if err != nil {
|
||||
fmt.Println("Error writing success response:", err)
|
||||
app.Server.Logger.Error("Error writing success response:", err)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/fossyy/filekeeper/app"
|
||||
"github.com/fossyy/filekeeper/types"
|
||||
"github.com/fossyy/filekeeper/types/models"
|
||||
@ -27,7 +26,6 @@ func (r *Service) GetUser(ctx context.Context, email string) (*models.User, erro
|
||||
userJSON, err := app.Server.Cache.GetCache(ctx, "UserCache:"+email)
|
||||
if err == redis.Nil {
|
||||
userData, err := r.db.GetUser(email)
|
||||
fmt.Println(userData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user