Merge pull request #55 from fossyy/staging
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)
|
newGoogleSetupJSON, _ := json.Marshal(user)
|
||||||
err = app.Server.Cache.SetCache(r.Context(), "GoogleSetup:"+code, newGoogleSetupJSON, time.Minute*15)
|
err = app.Server.Cache.SetCache(r.Context(), "GoogleSetup:"+code, newGoogleSetupJSON, time.Minute*15)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error setting up Google Setup:", err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, fmt.Sprintf("/auth/google/setup/%s", code), http.StatusSeeOther)
|
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()
|
_, message, err = conn.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||||
fmt.Println("Unexpected connection closure:", err)
|
app.Server.Logger.Error("Unexpected connection closure:", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Connection closed:", err)
|
app.Server.Logger.Error("Connection closed:", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var action WebsocketAction
|
var action WebsocketAction
|
||||||
err = json.Unmarshal(message, &action)
|
err = json.Unmarshal(message, &action)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error unmarshalling WebsocketAction:", err)
|
app.Server.Logger.Error("Error unmarshalling WebsocketAction:", err)
|
||||||
sendErrorResponse(conn, action.Action)
|
sendErrorResponse(conn, action.Action)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func handlerWS(conn *websocket.Conn, userSession types.User) {
|
|||||||
var uploadNewFile ActionUploadNewFile
|
var uploadNewFile ActionUploadNewFile
|
||||||
err = json.Unmarshal(message, &uploadNewFile)
|
err = json.Unmarshal(message, &uploadNewFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error unmarshalling ActionUploadNewFile:", err)
|
app.Server.Logger.Error("Error unmarshalling ActionUploadNewFile:", err)
|
||||||
sendErrorResponse(conn, action.Action)
|
sendErrorResponse(conn, action.Action)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -220,12 +220,12 @@ func sendErrorResponse(conn *websocket.Conn, action ActionType) {
|
|||||||
}
|
}
|
||||||
marshal, err := json.Marshal(response)
|
marshal, err := json.Marshal(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error marshalling error response:", err)
|
app.Server.Logger.Error("Error marshalling error response:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||||
if err != nil {
|
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)
|
marshal, err := json.Marshal(responseJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error marshalling success response:", err)
|
app.Server.Logger.Error("Error marshalling success response:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||||
if err != nil {
|
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)
|
marshal, err := json.Marshal(responseJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error marshalling success response:", err)
|
app.Server.Logger.Error("Error marshalling success response:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
err = conn.WriteMessage(websocket.TextMessage, marshal)
|
||||||
if err != nil {
|
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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"github.com/fossyy/filekeeper/app"
|
"github.com/fossyy/filekeeper/app"
|
||||||
"github.com/fossyy/filekeeper/types"
|
"github.com/fossyy/filekeeper/types"
|
||||||
"github.com/fossyy/filekeeper/types/models"
|
"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)
|
userJSON, err := app.Server.Cache.GetCache(ctx, "UserCache:"+email)
|
||||||
if err == redis.Nil {
|
if err == redis.Nil {
|
||||||
userData, err := r.db.GetUser(email)
|
userData, err := r.db.GetUser(email)
|
||||||
fmt.Println(userData)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user